From: mariusads at helpedia dot com Operating system: Windows 2003 Web Edition PHP version: 5.2.9 PHP Bug Type: Strings related Bug description: htmlentities, htmlspecialchars warnings don't appear on apache 1.3.33
Description: ------------ PHP 5.2.9-2 (cli) (built: Apr 9 2009 08:23:19) htmlspecialchars and htmlentities return empty strings when the text passed to them is not correct in the format you tell it, this is known. The problem I see is that the with an identical PHP.INI file, the following warnings are showing in logs when used with Apache 2.0.63 but don't appear when used with Apache 1.3.33 (and probably other 1.3.xx): [Thu Apr 16 20:12:53 2009] [error] [client x.x.x.x] PHP Warning: htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in D:\\website\\file.php on line 83 [Thu Apr 16 19:38:28 2009] [error] [client x.x.x.x] PHP Warning: htmlentities() [<a href='function.htmlentities'>function.htmlentities</a>]: Invalid multibyte sequence in argument in D:\\website\\file.php on line 83 These warnings appear on Apache 2.0.63, they don't appear on Apache 1.3.33 The INI is configured with error_reporting E_ALL (phpinfo shows error_reporting => 6143 => 6143) and even with E_ALL|E_STRICT the Apache 1.3.33 version doesn't show the warnings but does show recommendations about the date function and timezone settings so the error log clearly works. Reproduce code: --------------- Download the following NFO file: http://www.tgdb.net/temp/test.nfo Save it in the same folder where you'll run the following code: <?php $text = file_get_contents('test.nfo'); echo htmlspecialchars($text,ENT_QUOTES,'UTF-8'); echo htmlentities($text, ENT_QUOTES,'UTF-8'); echo 'Done'; ?> The NFO file above contains ASCII art done with characters with ascii code above 0x7F so it's an invalid UTF-8, therefore the functions will both fail returning an empty string. That's not the point here - though it's arguable if it's the best solution instead of just ignoring bad unicode chars - please continue reading The problem is I want to receive a warning, so that I'll be able to use error_get_last() and pass the text through a filter before trying to echo it again. In my case it's not possible to pre-filter all nfo files because some contain valid UTF-8 code and no ASCII art, others have only ASCII art. Expected result: ---------------- I should see warning messages in the logs no matter the Apache version. Actual result: -------------- On Apache 1.3.33, no warnings are shown when htmlentities and htmlspecialchars receive invalid text. -- Edit bug report at http://bugs.php.net/?id=47993&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47993&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47993&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47993&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47993&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47993&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47993&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47993&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47993&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47993&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47993&r=support Expected behavior: http://bugs.php.net/fix.php?id=47993&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47993&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47993&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47993&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47993&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47993&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47993&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47993&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47993&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47993&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47993&r=mysqlcfg
