#33553 [Opn->Csd]: get_html_translation_table() ambiguous
| From: | vrana@php.net | Date: | Fri, 08 Jul 2005 08:58:13 +0000 |
| Subject: | #33553 [Opn->Csd]: get_html_translation_table() ambiguous | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969368996@lists.php.net to get a copy of this message | ||
ID: 33553
Updated by: vrana@php.net
Reported By: goba@php.net
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.3.10
New Comment:
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.
"Special characters can be encoded in several ways. E.g. " can be
encoded as ", " or ". get_html_translation_table() returns
only the most common form for them."
Previous Comments:
------------------------------------------------------------------------
[2005-07-03 17:24:49] goba@php.net
Sorry, I mean single quote, as it is evidenced by the lxr link I
provided.
------------------------------------------------------------------------
[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