#45581 [Ver->Csd]: htmlspecialchars() double encoding &#x hex items

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45581
 Updated by:       [email protected]
 Reported By:      funky2step at gmail dot com
-Status:           Verified
+Status:           Closed
 Bug Type:         Strings related
 Operating System: Red Hat Enterprise Linux ES
 PHP Version:      5.2.6
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2008-07-22 14:40:29] funky2step at googlemail dot com

Thanks for the prompt reply. I understood though that this function
with double encode arg set to false would not act on _any_ existing html
entities.
Is there a reason why it does not recognize these codes, or is it an
oversight/bug?

------------------------------------------------------------------------

[2008-07-21 16:01:23] [email protected]

It's just that the function does not understand the hex entities. :)

------------------------------------------------------------------------

[2008-07-21 14:21:11] funky2step at gmail dot com

obviously that should have been $out = htmlspecialchars($str,
ENT_COMPAT, 'UTF-8', FALSE);
:)

------------------------------------------------------------------------

[2008-07-21 14:14:01] funky2step at gmail dot com

Description:
------------
Trying to use htmlspecialchars() on a string containing &#xHEX;
characters e.g. &#xA3;
With double encode set to false, it still converts the & to &amp;

Reproduce code:
---------------
$str = "&#xA3; one & two";
$out = htmlspecialchars($content, ENT_COMPAT, 'UTF-8', FALSE);
echo $out;

Expected result:
----------------
&#xA3; one &amp; two

Actual result:
--------------
&amp;#xA3; one &amp; two


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45581&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.