Skip to content

Commit e88ab74

Browse files
Merge branch 'PHP-7.0' into PHP-7.1
2 parents 46ecda7 + b59718b commit e88ab74

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55
- Core:
66
. Fixed bug #74947 (Segfault in scanner on INF number). (Laruence)
77
. Fixed bug #74954 (null deref and segfault in zend_generator_resume()). (Bob)
8+
. Fixed bug #74725 (html_errors=1 breaks unhandled exceptions). (Andrea)
89

910
- cURL:
1011
. Fixed bug #74125 (Fixed finding CURL on systems with multiarch support).

main/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
762762
buffer_len = (int)vspprintf(&buffer, 0, format, args);
763763

764764
if (PG(html_errors)) {
765-
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
765+
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, SG(default_charset));
766766
/* Retry with substituting invalid chars on fail. */
767767
if (!replace_buffer || ZSTR_LEN(replace_buffer) < 1) {
768-
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL);
768+
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, SG(default_charset));
769769
}
770770

771771
efree(buffer);
@@ -832,7 +832,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
832832
}
833833

834834
if (PG(html_errors)) {
835-
replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, NULL);
835+
replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, SG(default_charset));
836836
efree(origin);
837837
origin = ZSTR_VAL(replace_origin);
838838
}
@@ -1154,7 +1154,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
11541154

11551155
if (PG(html_errors)) {
11561156
if (type == E_ERROR || type == E_PARSE) {
1157-
zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
1157+
zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, SG(default_charset));
11581158
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));
11591159
zend_string_free(buf);
11601160
} else {

tests/output/bug74725.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #74725: html_errors=1 breaks unhandled exceptions
3+
--FILE--
4+
<?php
5+
ini_set('display_errors', 1);
6+
ini_set('html_errors', 1);
7+
ini_set('default_charset', "Windows-1251");
8+
throw new Exception("\xF2\xE5\xF1\xF2");
9+
// Note to test reader: this file is in Windows-1251 (vim: `:e ++enc=cp1251`)
10+
?>
11+
--EXPECTF--
12+
<br />
13+
<b>Fatal error</b>: Uncaught Exception: òåñò in %s:5
14+
Stack trace:
15+
#0 {main}
16+
thrown in <b>%s</b> on line <b>5</b><br />

0 commit comments

Comments
 (0)