Bug #73817 [Opn]: Incorrect entries in get_html_translation_table
| From: | cmb@php.net | Date: | Tue, 27 Dec 2016 12:13:26 +0000 |
| Subject: | Bug #73817 [Opn]: Incorrect entries in get_html_translation_table | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206220@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73817&edit=1
ID: 73817
Updated by: cmb@php.net
Reported by: philip at van-diemen-de-jel dot nl
Summary: Incorrect entries in get_html_translation_table
Status: Open
Type: Bug
-Package: unicodestring
+Package: Strings related
Operating System: Linux
PHP Version: 5.6.29
Block user comment: N
Private report: N
New Comment:
Actual result: <http://www.twentebestand.nl/pub/Test.php>.
Previous Comments:
------------------------------------------------------------------------
[2016-12-26 21:55:29] philip at van-diemen-de-jel dot nl
Description:
------------
PHP-version: 5.6.29-0+deb8u1 (on Linux plesk4.duocast.net 3.16.0-4-amd64 #1 SMP Debian
3.16.36-1+deb8u2 (2016-10-19) x86_64)
Some entries obtained from get_html_translation_table have a missing closing semicolon.
E.g. [8402] => &nvlt (should be <⃒)
[8421] => &bne
etc.
If you run the test script below (not the most sophisticated, but a quicky), the invalid entries
will be in red.
Test script:
---------------
$vec = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES | ENT_HTML5);
foreach ($vec as $key => $value) {
$dec = Utf2code( $key );
if (substr($value,-1,1)!=';') echo "<br>[$dec] => &<span
class=red>".substr($value,1)."</span> = $value;";
else echo "<br>[$dec] => &".substr($value,1)." = $value";
}
function Utf2code( $latin ) {
$magic = 128;
$i = $cnt = 0;
while ($i < strlen($latin) ) {
$kar = substr( $latin, $i, 1 );
$num = ord( $kar );
if (strlen($latin)==1) return( $num );
if ($num >= $magic) {
$cnt++;
$mask = $magic; $len = $utf = 0;
while ($mask & $num) { $len++; $mask = $mask/2; };
$utf = ($mask-1) & $num;
$j = 1;
while ($j < $len) {
$kar = substr( $latin, $i+$j, 1 );
if ((192 & ord( $kar )) != 128) break;
$utf = ($utf * 64) + (63 & ord($kar));
$j++;
};
if (($j==$len) and ($len<=6)) { //Assume UTF
return( $utf );
};
};
$i++;
};
return( -1 );
};
Expected result:
----------------
A dump of the html (entity) translation table, with incomplete entries flagged in red.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73817&edit=1