|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-27 15:24 UTC] dtajchreber@php.net
-Status: Open
+Status: Verified
[2011-03-11 13:42 UTC] pinkgothic at gmail dot com
[2016-03-25 03:11 UTC] Sicklife4life at gmail dot com
[2016-10-12 14:46 UTC] cmb@php.net
-Status: Verified
+Status: Closed
-Package: *Configuration Issues
+Package: Unknown/Other Function
-Assigned To:
+Assigned To: cmb
[2016-10-12 14:46 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
Description: ------------ Following functions may report E_WARNING when invalid utf8 sequence detected. json_encode htmlspecialchars htmlentities However, they only issue the warning if display_errors is OFF. display_errors should not dictate whether the warning is triggered. They behave this way because of following dumb logic in source code if (!PG(display_errors)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); } ext/standard/html.c php_escape_html_entities_ex ext/json/json.c json_escape_string This is more or less a repeat of http://bugs.php.net/bug.php?id=52397 which unfortunately got marked bogus. Test script: --------------- ini_set('display_errors', 1); json_encode("\xFF"); var_dump(error_get_last()); echo "-------\n"; ini_set('display_errors', 0); json_encode("\xFF"); var_dump(error_get_last()); //these have same problem //htmlspecialchars("\xFF", ENT_COMPAT, 'utf-8'); //htmlentities("\xFF", ENT_COMPAT, 'utf-8'); Expected result: ---------------- I expect both calls to error_get_last() should not return null. Also, I should have two entries in my error log. Actual result: -------------- First call to error_get_last() returns null, second call works. Only one message in error log.