PHP :: Bug #43314 :: iconv_mime_encode(), broken Q scheme
| Bug #43314 | iconv_mime_encode(), broken Q scheme | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2007-11-16 16:23 UTC | Modified: | 2010-03-02 10:24 UTC |
|
||||||||||
| From: | wiela at centras dot lt | Assigned: | rasmus (profile) | |||||||||||
| Status: | Closed | Package: | ICONV related | |||||||||||
| PHP Version: | 5.2.5 | OS: | Windows XP HE | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2007-11-16 16:23 UTC] wiela at centras dot lt
Description:
------------
iconv_mime_encode(),'Q' encoding scheme isn't reliable and
sometimes (for particular character and/or string length combination?) returns: "Notice: iconv_mime_encode(): Unknown error (7) in ..."
*without any result*.
This also applies to earlier php versions (tested with php 5.2.1).
Reproduce code:
---------------
$preferences = array(
"input-charset" => "UTF-8",
"output-charset" => "UTF-8",
"line-length" => 76,
"line-break-chars" => "\n",
"scheme" => "Q"
);
// $str1 results error, it's utf-8 string, its base64_encode() is:
//'xIXEjcSZxJfEr8WhxbPFviDEr8SZxI3FocWzxJnEr8SFIMSNxJnFs8SFxaHFs8Wr'
$str1 = "ąčęėį?ų? įęč?ųęįą čęųą?ųū";
// $str2 doesn't result error, although it's only one character
// shorter. It's utf-8 string, its base64_encode() is:
//'xIXEjcSZxJfEr8WhxbPFviDEr8SZxI3FocWzxJnEr8SFIMSNxJnFs8SFxaHFsw=='
$str2 = "ąčęėį?ų? įęč?ųęįą čęųą?ų";
echo iconv_mime_encode("Subject", $str1, $preferences);
echo iconv_mime_encode("Subject", $str2, $preferences);
Expected result:
----------------
Well, at least any (*some*) result is expected, without any
errors and warnings.
For $str1 is expected:
Subject: =?UTF-8?Q?=C4=85=C4=8D=C4=99=C4=97=C4=AF=C5=A1=C5=B3?=
=?UTF-8?Q?=C5=BE=20=C4=AF=C4=99=C4=8D=C5=A1=C5=B3=C4=99=C4=AF?=
=?UTF-8?Q?=C4=85=20=C4=8D=C4=99=C5=B3=C4=85=C5=A1=C5=B3=C5=AB?=
For $str2 is expected:
Subject: =?UTF-8?Q?=C4=85=C4=8D=C4=99=C4=97=C4=AF=C5=A1=C5=B3?=
=?UTF-8?Q?=C5=BE=20=C4=AF=C4=99=C4=8D=C5=A1=C5=B3=C4=99=C4=AF?=
=?UTF-8?Q?=C4=85=20=C4=8D=C4=99=C5=B3=C4=85=C5=A1=C5=B3?=
Actual result:
--------------
For $str1:
FALSE with "Notice: iconv_mime_encode(): Unknown error (7) in ..."
For $str2:
Subject: =?UTF-8?Q?=C4=85=C4=8D=C4=99=C4=97=C4=AF=C5=A1=C5=B3?=
=?UTF-8?Q?=C5=BE=20=C4=AF=C4=99=C4=8D=C5=A1=C5=B3=C4=99=C4=AF?=
=?UTF-8?Q?=C4=85=20=C4=8D=C4=99=C5=B3=C4=85=C5=A1=C5=B3?=
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-02-01 14:10 UTC] d_kelsey at uk dot ibm dot com
[2009-01-09 14:38 UTC] om at viazenetti dot de
[2009-11-28 22:18 UTC] dennispopel at gmail dot com
[2010-03-02 01:34 UTC] rasmus@php.net
-Status: No Feedback +Status: Closed