Bug #72752 [Opn->Ver]: mb_convert_encoding fails to convert chars from HTML-ENTITIES to some encodings

From: Date: Thu, 04 Aug 2016 12:11:48 +0000
Subject: Bug #72752 [Opn->Ver]: mb_convert_encoding fails to convert chars from HTML-ENTITIES to some encodings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202923@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72752&edit=1 ID: 72752 Updated by: cmb@php.net Reported by: contact at amb dot tf Summary: mb_convert_encoding fails to convert chars from HTML-ENTITIES to some encodings -Status: Open +Status: Verified Type: Bug Package: mbstring related Operating System: Arch Linux PHP Version: 7.0.9 Block user comment: N Private report: N New Comment: Confirmed: <https://3v4l.org/8u1h4>. The culprit is in mbfl_convert_filter_get_vtbl()[1], where the failing encodings simply assume the input is 8bit encoded. Just removing these shortcuts(?) would make the supplied test script pass (except for BASE64 encoding, which would report a). [1] <https://github.com/php/php-src/blob/PHP-7.0.9/ext/mbstring/libmbfl/mbfl/mbfl_convert.c#L581-L589> Previous Comments: ------------------------------------------------------------------------ [2016-08-03 23:45:57] contact at amb dot tf Description: ------------ mb_convert_encoding fails to convert HTML-ENTITIES encoded chars to the following encodings: * BASE64 * Quoted-Printable * 7bit Test script: --------------- <?php foreach ([ 'BASE64', 'UUENCODE', 'HTML-ENTITIES', 'Quoted-Printable', '7bit', '8bit', ] as $encoding) { echo "$encoding: ", mb_convert_encoding('&#x61;', $encoding, 'HTML-ENTITIES'), PHP_EOL; } Expected result: ---------------- BASE64: YQ== UUENCODE: a HTML-ENTITIES: a Quoted-Printable: a 7bit: a 8bit: a Actual result: -------------- BASE64: JiN4NjE7 UUENCODE: a HTML-ENTITIES: a Quoted-Printable: &#x61; 7bit: &#x61; 8bit: a ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72752&edit=1

« previous php.bugs (#202923) next »