|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-09-20 16:27 UTC] lzsiga at freemail dot c3 dot hu
Description: ------------ Printing an error message with settings 'html_errors=true' and 'default_charset=ISO-8859-2' leads to infinite loop. Components of the loop: determine_charset -> php_error_docref0 -> php_verror -> php_escape_html_entities -> php_escape_html_entities_ex -> determine_charset This bug was introduced in version 7.1.9, main/main.c line 765 before: replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL); after: php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, SG(default_charset)); (A note: The problem could be solved if htmlentities didn't verify UTF8-validity and silently ignored 'charset' parameter. See also: https://bugs.php.net/bug.php?id=47494 ) Test script: --------------- #!/usr/local/bin/php <?php ini_set('html_errors', true); ini_set('default_charset', 'ISO-8859-2'); printf ("before getfilecontent\n"); file_get_contents ('no/suchfile'); printf ("after getfilecontent\n"); ?> Expected result: ---------------- before getfilecontent PHP Warning: file_get_contents(no/suchfile): failed to open stream: No such file or directory in /local/home/projects/devel/phptest/loopy.php on line 8 <br /> <b>Warning</b>: file_get_contents(no/suchfile): failed to open stream: No such file or directory in <b>/local/home/projects/devel/phptest/loopy.php</b> on line <b>8</b><br /> after getfilecontent Actual result: -------------- before getfilecontent Segmentation fault PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
PHP strings are unaware of the character encoding, so basically any character encoding is supported. How these are handled exactly depends on the respective functions/methods. For instance, the character ļ (U+013C, of course!) is not handled well when given in UTF-16BE encoding to htmlentities(): <?php var_dump(htmlentities("\x01\x3c", ENT_COMPAT, 'UTF-16BE')); ?> outputs something like: Warning: htmlentities(): charset `UTF-16BE' not supported, assuming utf-8 string(5) "<" If the $encoding parameter is not set, or simply wrong, the result may be identical, but there may not even be a warning. It is the developers responsibility to properly deal with character encodings.