php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53377 imap_mime_header_decode() doesn't ignore \t during long MIME header unfolding
Submitted: 2010-11-22 12:48 UTC Modified: 2010-12-13 09:38 UTC
From: up at co dot inbox dot lv Assigned: aharvey
Status: Closed Package: IMAP related
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID:
 [2010-11-22 12:48 UTC] up at co dot inbox dot lv
Description:
------------
Function imap_mime_header_decode() doesn't respect \t (HTAB) characters marking continuation of header defined in RFC822 as one of the LWSP chars, however SPACE is still ignored. Source string:

{{{
public 'subject' => string '=?utf-8?B?V3VzaHUgaW5mb3JtIC0gU2FjZW5zaWJhcyBJZ2F1bmk=?=	=?utf-8?B?amEgKFRhbGxpbmEpLCDRgdC+0YDQtdCy0L3QvtCy0LDQvdC40Y8g0LIg0KLQsNC7?=	=?utf-8?B?0LvQuNC90LUgMTEg0LTQtdC60LDQsdGA0Y8=?=' (length=182)
}}}

where spaces between =?...?= lines are actually tabs, results to
{{{
array
  0 => 
    object(stdClass)[54]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'Wushu inform - Sacensibas Igauni' (length=32)
  1 => 
    object(stdClass)[53]
      public 'charset' => string 'default' (length=7)
      public 'text' => string '	' (length=1)
  2 => 
    object(stdClass)[55]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'ja (Tallina), соревнования в Тал' (length=48)
  3 => 
    object(stdClass)[56]
      public 'charset' => string 'default' (length=7)
      public 'text' => string '	' (length=1)
  4 => 
    object(stdClass)[57]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'лине 11 декабря' (length=26)

}}}

This produces:
{{{
Wushu inform - Sacensibas Igauni ja (Tallina), соревнования в Тал лине 11 декабря
}}}

with unwanted spaces in words "Igauni ja" and "Тал лине".

Test script:
---------------
    $str = "=?utf-8?B?V3VzaHUgaW5mb3JtIC0gU2FjZW5zaWJhcyBJZ2F1bmk=?="
        ."\t=?utf-8?B?amEgKFRhbGxpbmEpLCDRgdC+0YDQtdCy0L3QvtCy0LDQvdC40Y8g0LIg0KLQsNC7?="
        ."\t=?utf-8?B?0LvQuNC90LUgMTEg0LTQtdC60LDQsdGA0Y8=?=";

    var_dump(imap_mime_header_decode($str));
    var_dump(imap_mime_header_decode(str_replace("\t", " ", $str)))

Expected result:
----------------
array
  0 => 
    object(stdClass)[5]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'Wushu inform - Sacensibas Igauni' (length=32)
  1 => 
    object(stdClass)[4]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'ja (Tallina), б�аОб�аЕаВаНаОаВаАаНаИб� аВ аЂаАаЛ' (length=48)
  2 => 
    object(stdClass)[3]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'аЛаИаНаЕ 11 аДаЕаКаАаБб�б�' (length=26)


Actual result:
--------------
array
  0 => 
    object(stdClass)[1]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'Wushu inform - Sacensibas Igauni' (length=32)
  1 => 
    object(stdClass)[2]
      public 'charset' => string 'default' (length=7)
      public 'text' => string '	' (length=1)
  2 => 
    object(stdClass)[3]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'ja (Tallina), б�аОб�аЕаВаНаОаВаАаНаИб� аВ аЂаАаЛ' (length=48)
  3 => 
    object(stdClass)[4]
      public 'charset' => string 'default' (length=7)
      public 'text' => string '	' (length=1)
  4 => 
    object(stdClass)[5]
      public 'charset' => string 'utf-8' (length=5)
      public 'text' => string 'аЛаИаНаЕ 11 аДаЕаКаАаБб�б�' (length=26)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-23 11:35 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=305686
Log: Fix bug #53377 (imap_mime_header_decode() doesn't ignore \t during long MIME
header unfolding).
 [2010-11-23 11:36 UTC] aharvey@php.net
-Status: Open +Status: Suspended -Assigned To: +Assigned To: aharvey
 [2010-11-23 11:36 UTC] aharvey@php.net
Fixed on trunk. I'll verify that we want this for 5.3.4 before
committing it onto the 5.3 branch, since we're in a release cycle
at present.
 [2010-12-13 09:38 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=306336
Log: MFH: fixed bug #53377 (imap_mime_header_decode() doesn't ignore \t during long
MIME header unfolding).
 [2010-12-13 09:38 UTC] aharvey@php.net
-Status: Suspended +Status: Closed
 [2010-12-13 09:38 UTC] aharvey@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Merged to 5.3.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 22:02:16 2014 UTC