Bug #60884 [NEW]: htmlentities() behaves differently and thus breaks existing code
From:
Operating system: CentOS 4.4
PHP version: 5.4.0RC6
Package: *General Issues
Bug Type: Bug
Bug description:htmlentities() behaves differently and thus breaks existing code
Description:
------------
//This code must be run via web:
//This is a string from e.g. some database containing a german umlaut 'ä'.
Note the encoding really is iso8859-1 . It's just assigned here literally
to be concise.
$a = "Rechnungsadresse ändern";
//this output works: (An empty string activates some autodetection)
var_dump(htmlentities($a, ENT_COMPAT | ENT_HTML401, ''));
//this works too (the same output is generated):
var_dump(htmlentities($a, ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'));
//this does NOT work (outputs empty string)
var_dump(htmlentities($a));
// Reason: php changed the charset htmlentities uses when you NOT give
anything (90% of the code out there):
//determine_charset() :
///////////////////////////////////////////////////////
// php-5.2.1/ext/standard/html.c :
// /* Guarantee default behaviour for backwards compatibility */
// if (charset_hint == NULL)
// return cs_8859_1;
/////////////////////////////////////////////////////
// php-5.4.0RC4/ext/standard/html.c :
// /* Default is now UTF-8 */
// if (charset_hint == NULL)
// return cs_utf_8;
// This breaks the meaning of existing german code. For example, typo3
outputs empty string if end users used german umlauts in rich text editor
in backend.
// Please change determine_charset() back to using cs_8859_1 if the third
parameter of htmlentities() is omitted.
Test script:
---------------
See description.
Expected result:
----------------
See description.
Actual result:
--------------
See description.
--
Edit bug report at https://bugs.php.net/bug.php?id=60884&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60884&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60884&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60884&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60884&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60884&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60884&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60884&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60884&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60884&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60884&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60884&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60884&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60884&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60884&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60884&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60884&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60884&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60884&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60884&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60884&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60884&r=mysqlcfg
Thread (4 messages)
- t dot nickl at exse dot de