#40017 [NEW]: htmlentities double escaping
| From: | thedewi at hotmail dot com | Date: | Thu, 04 Jan 2007 03:46:34 +0000 |
| Subject: | #40017 [NEW]: htmlentities double escaping | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-107157@lists.php.net to get a copy of this message | ||
From: thedewi at hotmail dot com
Operating system: Debian with bpo backport
PHP version: 5.2.0
PHP Bug Type: Strings related
Bug description: htmlentities double escaping
Description:
------------
For some UTF-8 characters, htmlentities() returns...
&#nnnn;
... when it should return ...
&#nnnn;
The problem does not seem to occur in the punctuation or currency
subranges, but many subranges are affected including: drawing, greek,
cyrillic, hebrew.
It has been partially fixed in the past:
http://bugs.php.net/bug.php?id=11175
There has also been at least one other bug report, filed "Bogus" without a
very detailed explanation:
http://bugs.php.net/bug.php?id=27691
Presumably the above was a misunderstanding, but if you get the urge to
mark this bug as "Bogus", please explain it, because this behaviour seems
to result in unpredictable and ambiguous results (by which I mean that
applying a workaround will give false positives).
Reproduce code:
---------------
<?php
print 'Form:<form action="?" method="post"><input
type="text" name="foo"
size="80" value="' . htmlentities(stripslashes($_POST['foo']),
ENT_QUOTES,
'UTF-8') . '"/></form>Thanks.';
?>
Expected result:
----------------
When I enter text into the input field, it should render a correctly
represented and escaped value in the resulting markup:
»¥Ω∏░☺ψЭש ك
Note: it seems this bug report form itself suffers from a similar problem,
so keep in mind that the above are unicode characters, not HTML escapes.
Actual result:
--------------
ȴ&#8486;&#8719;&#9617;&#9786;&#968;&#1069;&#1513;
&#1603;
As you can see, the first few translations were correct, but the more
exotic ones failed.
--
Edit bug report at http://bugs.php.net/?id=40017&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40017&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40017&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40017&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40017&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40017&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40017&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40017&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40017&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40017&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40017&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40017&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40017&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40017&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40017&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40017&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40017&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40017&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40017&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40017&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40017&r=mysqlcfg