Bug #73817 [Ver->Csd]: Incorrect entries in get_html_translation_table

From: Date: Sun, 15 Jul 2018 21:43:08 +0000
Subject: Bug #73817 [Ver->Csd]: Incorrect entries in get_html_translation_table
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216342@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: Verified +Status: Closed Type: Bug Package: Strings related Operating System: Linux PHP Version: 5.6.29 Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=0f8c1ee76d5d2aa90bf667215e41eed60ca6cbcd Log: Fix #73817: Incorrect entries in get_html_translation_table Previous Comments: ------------------------------------------------------------------------ [2016-12-27 13:54:05] cmb@php.net Confirmed: <https://3v4l.org/4VOk1>. The following looks fishy: <https://github.com/php/php-src/blob/PHP-7.1.0/ext/standard/html.c#L1600-L1601>. ------------------------------------------------------------------------ [2016-12-27 12:13:55] cmb@php.net Related To: Bug #73818 ------------------------------------------------------------------------ [2016-12-27 12:13:25] cmb@php.net Actual result: <http://www.twentebestand.nl/pub/Test.php>. ------------------------------------------------------------------------ [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 &nvlt;) [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] => &amp;<span class=red>".substr($value,1)."</span> = $value;"; else echo "<br>[$dec] => &amp;".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

« previous php.bugs (#216342) next »