#33553 [Opn]: get_html_translation_table() ambiguous
| From: | goba@php.net | Date: | Sun, 03 Jul 2005 15:24:50 +0000 |
| Subject: | #33553 [Opn]: get_html_translation_table() ambiguous | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969368909@lists.php.net to get a copy of this message | ||
ID: 33553
Updated by: goba@php.net
Reported By: goba@php.net
Status: Open
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.3.10
New Comment:
Sorry, I mean single quote, as it is evidenced by the lxr link I
provided.
Previous Comments:
------------------------------------------------------------------------
[2005-07-03 17:15:31] derick@php.net
You surely mean slash here, and not ampersand? Anyway, this is not a
PHP bug but a documentation issue.
------------------------------------------------------------------------
[2005-07-03 17:09:54] goba@php.net
Description:
------------
get_html_translation_table() returns an array with two keys having
value "'" (the ampersand). When array_flip()-ed, as suggested by the
manual, the second one overwrites the first, thus giving a reverse
table with only one ampersand key. Using this reverse table to convert
back a string is not possible, since the original table had the other
representation of the ampersand first, and used that for translation.
See http://lxr.php.net/source/php-src/ext/standard/html.c#466
Note that if this is not deemed to be a PHP bug, then this
irreversibility issue should be documented.
Reproduce code:
---------------
var_dump(htmlspecialchars("'", ENT_QUOTES));
var_dump(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES));
var_dump(array_flip(get_html_translation_table(HTML_SPECIALCHARS,
ENT_QUOTES)));
Expected result:
----------------
No ambigous array elements in the translation table.
Actual result:
--------------
Two entries for the ampersand.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33553&edit=1