From b59718bdc439f82fa1beae2c4ea1582c38bc8de3 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Sat, 12 Aug 2017 01:35:27 +0100 Subject: Fix bug #74725 (html_errors=1 breaks unhandled exceptions) --- NEWS | 1 + main/main.c | 8 ++++---- tests/output/bug74725.phpt | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/output/bug74725.phpt diff --git a/NEWS b/NEWS index a1f33f209d..5fc4f75616 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 4b145fcc70..81e1222796 100644 --- a/main/main.c +++ b/main/main.c @@ -722,10 +722,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); @@ -792,7 +792,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); } @@ -1106,7 +1106,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
\n%s: %s in %s on line %d
\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-- + +--EXPECTF-- +
+Fatal error: Uncaught Exception: тест in %s:5 +Stack trace: +#0 {main} + thrown in %s on line 5
-- cgit v1.2.1