From: Development at JivanAmara dot net Operating system: Linux (Ubuntu / Redhat) PHP version: Irrelevant Package: IMAP related Bug Type: Bug Bug description:imap_utf8 returns bad utf8 string
Description: ------------ MIME 'from' header "=?gb18030?B?zfW+/L3c?=" is not converted to utf-8. Instead the gb18030 encoding is returned. I expect in versions < 5.4.0 a warning indicating unsupported character set and an empty string returned. I expect in versions >= 5.4.0 a correctly converted utf-8 encoding of the text. Behavior has been checked with versions 5.2.9, 5.3.?, 5.4.6 Test script: --------------- <?php $from = '=?gb18030?B?zfW+/L3c?='; $from_imap_utf8 = imap_utf8($from); echo "imap_utf8: $from_imap_utf8", "\n"; $from_obj = imap_mime_header_decode($from); $charset = $from_obj[0]->charset; $text = $from_obj[0]->text; $text_utf8 = mb_convert_encoding($text, 'UTF-8', $charset); echo "decode/convert: $text_utf8", "\n"; echo "Correct conversion: ", $from_imap_utf8 == $text_utf8 ? "Yes" : "No", "\n"; ?> Expected result: ---------------- For versions >= 5.4.0 I expect the script to output: imap_utf8: çåæ° decode/convert: çåæ° Correct conversion: Yes For versions < 5.4.0 I expect the script to output: PHP Warning: imap_utf8(): Illegal character encoding specified in <script name> on line 4 imap_utf8: PHP Warning: mb_convert_encoding(): Illegal character encoding specified in <script name> on line 10 decode/convert: Correct conversion: Yes Actual result: -------------- For versions >= 5.4.0 I see: imap_utf8: ����� decode/convert: çåæ° Correct conversion: No For versions < 5.4.0 I see: imap_utf8: ����� PHP Warning: mb_convert_encoding(): Illegal character encoding specified in /home/netcloud/jivan.amara/encoding.php on line 20 decode/convert: Correct conversion: No -- Edit bug report at https://bugs.php.net/bug.php?id=63266&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63266&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63266&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63266&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63266&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63266&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63266&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63266&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63266&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63266&r=support Expected behavior: https://bugs.php.net/fix.php?id=63266&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63266&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63266&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63266&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63266&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63266&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63266&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63266&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63266&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63266&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63266&r=mysqlcfg