Bug #60494 [Opn->Ver]: iconv_mime_decode does ignore special characters
| From: | cmb@php.net | Date: | Sun, 11 Mar 2018 23:12:50 +0000 |
| Subject: | Bug #60494 [Opn->Ver]: iconv_mime_decode does ignore special characters | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214291@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60494&edit=1
ID: 60494
Updated by: cmb@php.net
Reported by: bin at webcandy dot at
Summary: iconv_mime_decode does ignore special characters
-Status: Open
+Status: Verified
Type: Bug
Package: ICONV related
Operating System: Windows 7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
iconv_mime_decode() is supposed to decode a MIME header according
to RFC 2047. Neither 'ä', 'ö' nor 'Ã' are valid characters in
headers, so returning these characters unmodified would be wrong.
However, it is not correct to simply skip invalid characters.
Instead the function should fail (i.e. return FALSE). It seems
the problem is that inside of _php_iconv_mime_decode() all calls
to _php_iconv_appendc() ignore its return value (although all
calls to _php_iconv_appendl() cater to it). In this case the
culprit is:
<https://github.com/php/php-src/blob/php-7.2.3/ext/iconv/iconv.c#L1538>
Previous Comments:
------------------------------------------------------------------------
[2011-12-11 21:16:22] bin at webcandy dot at
Expected result should probably have 2 bytes as I expect it to be UTF-8 when using
iconv.output_encoding = UTF-8
Exptected result:
----------------
string(2) "ä"
string(2) "ö"
string(2) "Ã"
------------------------------------------------------------------------
[2011-12-11 21:12:35] bin at webcandy dot at
Description:
------------
If the string $text passed to iconv_mime_decode($text) does contain special characters (tested with
ä, ü and Ã), it will just return an empty character for these characters.
In my opinion it iconv_mime_decode should leave special characters as they are as long as
they're not encoded via Q-encoding.
Tested on Windows 7 and Debian.
iconv.output_encoding is set to "UTF-8"
Test script:
---------------
<?php
var_dump(iconv_mime_decode('ä'));
var_dump(iconv_mime_decode('ö'));
var_dump(iconv_mime_decode('Ã'));
?>
Expected result:
----------------
string(1) "ä"
string(1) "ö"
string(1) "Ã"
Actual result:
--------------
string(0) ""
string(0) ""
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60494&edit=1