php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63839 iconv_mime_decode_headers function is skipping headers
Submitted: 2012-12-23 14:48 UTC Modified: 2015-09-09 12:46 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: nidhikaushal28 at gmail dot com Assigned: aharvey
Status: Verified Package: ICONV related
PHP Version: 5.3.20 OS: Windows 7, CentOS
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-12-23 14:48 UTC] nidhikaushal28 at gmail dot com
Description:
------------
iconv_mime_decode_headers function is skipping headers when '=?' is present in the subject. 

For example if the subject header of a mime message is : 
Subject: Reply Is? white side-LED =? in Help

Then the rest of the headers after subject like content-type, date etc are not returned. Similar bug is filed https://bugs.php.net/bug.php?id=52941 but in the above mentioned example the subject is not encoded. 

My php version is 5.3.3 and the issue is reproducible in 5.3.20 and 5.4.10. 

Test script:
---------------
<?php
$headers = 'From: "xyz" <xyz@xyz.com>
To: <xyz@xyz.com>
Subject: Reply Is? white side-LED =? in Help
Date: Sat, 22 Dec 2012
Message-ID: <006f01cde00e$d9f79da0$8de6d8e0>
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Ac3gDtcH2huHjzYcQVmFJPPoWjJogA==
Content-Language: en-us

';
$headers = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
print_r($headers);
?>

Expected result:
----------------
Array
(
    [From] => "xyz" <xyz@xyz.com>
    [To] => <xyz@xyz.com>
    [Subject] => Reply Is? white side-LED =? in Help
    [Date] => Sat, 22 Dec 2012
    [Message-ID] => <006f01cde00e$d9f79da0$8de6d8e0>
    [MIME-Version] => 1.0
    [Content-Type] => multipart/alternative; boundary="----=_NextPart_000_0070_0
1CDE03C.F3AFD9A0"
    [X-Mailer] => Microsoft Office Outlook 12.0
    [Thread-Index] => Ac3gDtcH2huHjzYcQVmFJPPoWjJogA==
    [Content-Language] => en-us
)

Actual result:
--------------
Array
(
    [From] => "xyz" <xyz@xyz.com>
    [To] => <xyz@xyz.com>
    [Subject] => Reply Is? white side-LED
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-23 17:46 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2013-01-08 16:52 UTC] Chandakme at gmail dot com
I am also facing same issue and would like to hear more about it?
 [2015-09-09 12:46 UTC] cmb@php.net
-Status: Assigned +Status: Verified
 [2015-09-09 12:46 UTC] cmb@php.net
Confirmed: <https://3v4l.org/9Yb90>

Apparently a problem with wrong detection of encoded words.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC