Bug #60884 [Com]: htmlentities() behaves differently and thus breaks existing code
| From: | t dot nickl at exse dot de | Date: | Fri, 24 Feb 2012 09:27:20 +0000 |
| Subject: | Bug #60884 [Com]: htmlentities() behaves differently and thus breaks existing code | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7995@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60884&edit=1
ID: 60884
Comment by: t dot nickl at exse dot de
Reported by: t dot nickl at exse dot de
Summary: htmlentities() behaves differently and thus breaks
existing code
Status: Closed
Type: Bug
Package: Documentation problem
Operating System: CentOS 4.4
PHP Version: 5.4.0RC6
Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
foreach(array(chr(195).chr(132) /*utf8*/, chr(196) /*latin1*/) as $germanUmlaut)
{
$str= 'a'.$germanUmlaut.'de';
$pos= strpos($str, $germanUmlaut);
var_dump(htmlentities($str));
var_dump($pos);
var_dump(substr($str, $pos, 1));
}
/*
on php5.3.10:
string(12) "aÃ<secondbyteofutf8umlaut>de"
int(1)
string(1) "<firstbyteofutf8umlaut>"
string(9) "aÄde"
int(1)
string(1) "<latin1umlaut>"
on php5.4:
string(9) "aÄde"
int(1)
string(1) "<firstbyteofutf8umlaut>"
string(0) ""
int(1)
string(1) "<latin1umlaut>"
I find it very funny that htmlentities assumes utf8 now, but substr is still thinking in latin1, as
it gives only back the first byte of a multibyte character (seen above).
Previous Comments:
------------------------------------------------------------------------
[2012-01-27 10:00:22] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
------------------------------------------------------------------------
[2012-01-27 10:00:16] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=322842
Log: Fix doc bug #60884 (htmlentities() behaves differently and thus breaks existing
code) by clarifying the new behaviour in PHP 5.4.0.
------------------------------------------------------------------------
[2012-01-26 23:00:03] sixd@php.net
Re-opening as a Doc bug. The htmlentities doc needs to be clearer about this. Its "this
default is very likely to change" text is outdated.
------------------------------------------------------------------------
[2012-01-26 09:18:09] t dot nickl at exse dot de
@johannes@php.net:
Setting default_charset to latin1 does not work. Empty string is still outputted when calling
htmlentities with only one argument.
Your copy&paste preamble does not help, changing the meaning of the written code is a bug,
don't worry.
@rasmus@php.net:
Thank you, I sadly will change every htmlentities($a) to htmlentities($a,NULL,'') before
deploying php5.4.
------------------------------------------------------------------------
[2012-01-25 22:52:52] rasmus@php.net
I know it hurts, but we really need to move away from ISO-8859-1 and towards
UTF-8 as the default charset of the Web. We have chosen to take the hit in 5.4.
The documentation has carried a warning about this impending change for quite a
while urging people to specify a charset.
For PHP 5.4 compatibility Typo3 should either hardcode iso-8859-1 or they should
change their calls to:
htmlentities($a,NULL,'')
to pick up the default script-encoding charset.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=60884
--
Edit this bug report at https://bugs.php.net/bug.php?id=60884&edit=1