summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2017-08-12 01:37:47 +0100
committerAndrea Faulds <ajf@ajf.me>2017-08-12 01:37:47 +0100
commite88ab7488602fa7141c44db53fd52b0a6a9fcae0 (patch)
tree9755e747accf7d13dc8fff9ab789ab47bd0ec2d8
parent46ecda76ba2989957c9f6d049d76d6e668918d12 (diff)
parentb59718bdc439f82fa1beae2c4ea1582c38bc8de3 (diff)
downloadphp-git-e88ab7488602fa7141c44db53fd52b0a6a9fcae0.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r--NEWS1
-rw-r--r--main/main.c8
-rw-r--r--tests/output/bug74725.phpt16
3 files changed, 21 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 39449d401b..b1068f1feb 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP NEWS
- Core:
. Fixed bug #74947 (Segfault in scanner on INF number). (Laruence)
. Fixed bug #74954 (null deref and segfault in zend_generator_resume()). (Bob)
+ . Fixed bug #74725 (html_errors=1 breaks unhandled exceptions). (Andrea)
- cURL:
. Fixed bug #74125 (Fixed finding CURL on systems with multiarch support).
diff --git a/main/main.c b/main/main.c
index 863daec18a..f812b33e66 100644
--- a/main/main.c
+++ b/main/main.c
@@ -762,10 +762,10 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
buffer_len = (int)vspprintf(&buffer, 0, format, args);
if (PG(html_errors)) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
+ replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, SG(default_charset));
/* Retry with substituting invalid chars on fail. */
if (!replace_buffer || ZSTR_LEN(replace_buffer) < 1) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL);
+ replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, SG(default_charset));
}
efree(buffer);
@@ -832,7 +832,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
if (PG(html_errors)) {
- replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, NULL);
+ replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, SG(default_charset));
efree(origin);
origin = ZSTR_VAL(replace_origin);
}
@@ -1154,7 +1154,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
if (PG(html_errors)) {
if (type == E_ERROR || type == E_PARSE) {
- zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
+ zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, SG(default_charset));
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string));
zend_string_free(buf);
} else {
diff --git a/tests/output/bug74725.phpt b/tests/output/bug74725.phpt
new file mode 100644
index 0000000000..fc4e98b3e0
--- /dev/null
+++ b/tests/output/bug74725.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #74725: html_errors=1 breaks unhandled exceptions
+--FILE--
+<?php
+ini_set('display_errors', 1);
+ini_set('html_errors', 1);
+ini_set('default_charset', "Windows-1251");
+throw new Exception("\xF2\xE5\xF1\xF2");
+// Note to test reader: this file is in Windows-1251 (vim: `:e ++enc=cp1251`)
+?>
+--EXPECTF--
+<br />
+<b>Fatal error</b>: Uncaught Exception: тест in %s:5
+Stack trace:
+#0 {main}
+ thrown in <b>%s</b> on line <b>5</b><br />