php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60359 imap_rfc822_parse_headers parses overquoted letter body
Submitted: 2011-11-22 14:43 UTC Modified: 2020-10-18 04:22 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:2 (33.3%)
From: prokern at mail dot ru Assigned: cmb (profile)
Status: No Feedback Package: IMAP related
PHP Version: 5.3.8 OS: Windows XP SP3/OpenSUSE
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-11-22 14:43 UTC] prokern at mail dot ru
Description:
------------
Good day!

imap_rfc822_parse_headers is trying to parse overquoted rfc822 letter.

file with letter source for test can be obtained by link: 

http://webfile.ru/5685845

General structure:

	Received: from Techno-Mailbox.techno.elar.local ([192.168.30.4]) by
 techno-mailbox ([192.168.30.4]) with mapi; Wed, 16 Nov 2011 13:03:12 +0400
From: =?koi8-r?Q?=E2=C5=CC=CF=D7_=F3=C5=D2=C7=C5=CA?= <Sbelov@elar.ru>
To: =?koi8-r?Q?=F3=C4=D7=C9=D6=CB=CF=D7_=E1=CC=D8=C2=C5=D2=D4?= <asdvigkov@elar.ru>
Date: Wed, 16 Nov 2011 12:00:48 +0300
Subject:
 =?koi8-r?B?Rlc6IO/Sx8HOydrBw8nRIFJhaWQtzcHT08nXwSDOwSDTxdLXxdLFIOHz9SDz?=
 =?koi8-r?B?yyDEzNEg0NLPxcvUz9cg6/AxNTjw?=
Thread-Topic:
 =?koi8-r?B?79LHwc7J2sHDydEgUmFpZC3NwdPTydfBIM7BINPF0tfF0sUg4fP1IPPLIMTM?=
 =?koi8-r?B?0SDQ0s/Fy9TP1yDr8DE1OPA=?=
Thread-Index: AcykL9kUOYSp27TdSzG9fv1U7pZmtwAC6KYAAACmlLA=
Message-ID: <E4A56102102B144890018A88CFB5852C2155936598@techno-mailbox>
Accept-Language: ru-RU
Content-Language: ru-RU
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 03
X-MS-Exchange-Organization-AuthSource: Techno-Mailbox.techno.elar.local
X-MS-Has-Attach: yes
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
acceptlanguage: ru-RU
Content-Type: multipart/related;
	boundary="_004_E4A56102102B144890018A88CFB5852C2155936598technomailbox_";
	type="multipart/alternative"
MIME-Version: 1.0

--_004_E4A56102102B144890018A88CFB5852C2155936598technomailbox_
Content-Type: multipart/alternative;
	boundary="_000_E4A56102102B144890018A88CFB5852C2155936598technomailbox_"

--_000_E4A56102102B144890018A88CFB5852C2155936598technomailbox_
Content-Type: text/plain; charset="koi8-r"
Content-Transfer-Encoding: quoted-printable

=E1=CC=D8=C2=C5=D2=D4!

=F7=CF=D4 =D4=C1=CB =C4=CF=CC=D6=CE=CF =C2=D9=D4=D8 =D0=CF =D2=C5=C7=CC=C1=
=CD=C5=CE=D4=D5.




=F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD,
=E2=C5=CC=CF=D7 =F3=C5=D2=C7=C5=CA





ELAR

=EB=CF=D2=D0=CF=D2=C1=C3=C9=D1 <=FC=CC=C5=CB=D4=D2=CF=CE=CE=D9=CA =E1=D2=C8=
=C9=D7>
127083 =ED=CF=D3=CB=D7=C1, =F0=C5=D4=D2=CF=D7=D3=CB=CF-=F2=C1=DA=D5=CD=CF=
=D7=D3=CB=C1=D1 =C1=CC=CC=C5=D1, 12=C1
=F4=C5=CC=C5=C6=CF=CE +7 (495) 792-3131 #, =E6=C1=CB=D3 +7 (499) 251-3603
E-mail:  sbelov@elar.ru<mailto:sbelov@elar.ru>  =C9=CE=D4=C5=D2=CE=C5=D4-=
=C1=C4=D2=C5=D3: www.elar.ru<http://www.elar.ru>





  _____

From: =E7=CF=D2=C4=C9=C5=CE=CB=CF =F3=C5=D2=C7=C5=CA
Sent: Wednesday, November 16, 2011 1:42 PM
To: =E2=C5=CC=CF=D7 =F3=C5=D2=C7=C5=CA
Subject: RE: =EF=D2=C7=C1=CE=C9=DA=C1=C3=C9=D1 Raid-=CD=C1=D3=D3=C9=D7=C1 =
=CE=C1 =D3=C5=D2=D7=C5=D2=C5 =E1=F3=F5 =F3=CB =C4=CC=D1 =D0=D2=CF=C5=CB=D4=
=CF=D7 =EB=F0158=F0

...

Test script:
---------------
$fh	=	fopen("1.txt", "r");
$data	=	fread($fh,filesize("c:\\1.txt"));
$ob	=	imap_rfc822_parse_headers($data);
var_dump($ob);
fclose($fh);

Expected result:
----------------
object(stdClass)[1]
  public 'date' => string 'Wed, 16 Nov 2011 12:00:48 +0300' (length=31)
  public 'Date' => string 'Wed, 16 Nov 2011 12:00:48 +0300' (length=31)
  public 'subject' => string '=?koi8-r?B?Rlc6IO/Sx8HOydrBw8nRIFJhaWQtzcHT08nXwSDOwSDTxdLXxdLFIOHz9SDz?= =?koi8-r?B?yyDEzNEg0NLPxcvUz9cg6/AxNTjw?=' (length=115)
  public 'Subject' => string '=?koi8-r?B?Rlc6IO/Sx8HOydrBw8nRIFJhaWQtzcHT08nXwSDOwSDTxdLXxdLFIOHz9SDz?= =?koi8-r?B?yyDEzNEg0NLPxcvUz9cg6/AxNTjw?=' (length=115)
  public 'message_id' => string '<E4A56102102B144890018A88CFB5852C2155936598@techno-mailbox>' (length=59)
  public 'toaddress' => string '=?koi8-r?Q?=F3=C4=D7=C9=D6=CB=CF=D7_=E1=CC=D8=C2=C5=D2=D4?= <asdvigkov@elar.ru>, =E2=C5=CC=CF=D7@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR.", =E7=CF=D2=C4=C9=C5=CE=CB=CF@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."' (length=237)
  public 'to' => 
    array
      0 => 
        object(stdClass)[2]
          public 'personal' => string '=?koi8-r?Q?=F3=C4=D7=C9=D6=CB=CF=D7_=E1=CC=D8=C2=C5=D2=D4?=' (length=59)
          public 'mailbox' => string 'asdvigkov' (length=9)
          public 'host' => string 'elar.ru' (length=7)

Actual result:
--------------
object(stdClass)[1]
  public 'date' => string 'Wed, 16 Nov 2011 12:00:48 +0300' (length=31)
  public 'Date' => string 'Wed, 16 Nov 2011 12:00:48 +0300' (length=31)
  public 'subject' => string '=?koi8-r?B?Rlc6IO/Sx8HOydrBw8nRIFJhaWQtzcHT08nXwSDOwSDTxdLXxdLFIOHz9SDz?= =?koi8-r?B?yyDEzNEg0NLPxcvUz9cg6/AxNTjw?=' (length=115)
  public 'Subject' => string '=?koi8-r?B?Rlc6IO/Sx8HOydrBw8nRIFJhaWQtzcHT08nXwSDOwSDTxdLXxdLFIOHz9SDz?= =?koi8-r?B?yyDEzNEg0NLPxcvUz9cg6/AxNTjw?=' (length=115)
  public 'message_id' => string '<E4A56102102B144890018A88CFB5852C2155936598@techno-mailbox>' (length=59)
  public 'toaddress' => string '=?koi8-r?Q?=F3=C4=D7=C9=D6=CB=CF=D7_=E1=CC=D8=C2=C5=D2=D4?= <asdvigkov@elar.ru>, =E2=C5=CC=CF=D7@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR.", =E7=CF=D2=C4=C9=C5=CE=CB=CF@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."' (length=237)
  public 'to' => 
    array
      0 => 
        object(stdClass)[2]
          public 'personal' => string '=?koi8-r?Q?=F3=C4=D7=C9=D6=CB=CF=D7_=E1=CC=D8=C2=C5=D2=D4?=' (length=59)
          public 'mailbox' => string 'asdvigkov' (length=9)
          public 'host' => string 'elar.ru' (length=7)
      1 => 
        object(stdClass)[3]
          public 'mailbox' => string '=E2=C5=CC=CF=D7' (length=15)
          public 'host' => string 'UNKNOWN' (length=7)
      2 => 
        object(stdClass)[4]
          public 'mailbox' => string 'UNEXPECTED_DATA_AFTER_ADDRESS' (length=29)
          public 'host' => string '.SYNTAX-ERROR.' (length=14)
      3 => 
        object(stdClass)[5]
          public 'mailbox' => string '=E7=CF=D2=C4=C9=C5=CE=CB=CF' (length=27)
          public 'host' => string 'UNKNOWN' (length=7)
      4 => 
        object(stdClass)[6]
          public 'mailbox' => string 'UNEXPECTED_DATA_AFTER_ADDRESS' (length=29)
          public 'host' => string '.SYNTAX-ERROR.' (length=14)
  public 'fromaddress' => string '=?koi8-r?Q?=E2=C5=CC=CF=D7_=F3=C5=D2=C7=C5=CA?= <Sbelov@elar.ru>, =E7=CF=D2=C4=C9=C5=CE=CB=CF@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR.", =E2=C5=CC=CF=D7@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."' (length=222)
  public 'from' => 
    array
      0 => 
        object(stdClass)[7]
          public 'personal' => string '=?koi8-r?Q?=E2=C5=CC=CF=D7_=F3=C5=D2=C7=C5=CA?=' (length=47)
          public 'mailbox' => string 'Sbelov' (length=6)
          public 'host' => string 'elar.ru' (length=7)
      1 => 
        object(stdClass)[8]
          public 'mailbox' => string '=E7=CF=D2=C4=C9=C5=CE=CB=CF' (length=27)
          public 'host' => string 'UNKNOWN' (length=7)
      2 => 
        object(stdClass)[9]
          public 'mailbox' => string 'UNEXPECTED_DATA_AFTER_ADDRESS' (length=29)
          public 'host' => string '.SYNTAX-ERROR.' (length=14)
      3 => 
        object(stdClass)[10]
          public 'mailbox' => string '=E2=C5=CC=CF=D7' (length=15)
          public 'host' => string 'UNKNOWN' (length=7)
      4 => 
        object(stdClass)[11]
          public 'mailbox' => string 'UNEXPECTED_DATA_AFTER_ADDRESS' (length=29)
          public 'host' => string '.SYNTAX-ERROR.' (length=14)
  public 'reply_toaddress' => string '=?koi8-r?Q?=E2=C5=CC=CF=D7_=F3=C5=D2=C7=C5=CA?= <Sbelov@elar.ru>, =E7=CF=D2=C4=C9=C5=CE=CB=CF@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR.", =E2=C5=CC=CF=D7@UNKNOWN, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."' (length=222)
  


( ! ) Notice: Unknown: Unexpected characters at end of address: =F3=C5=D2=C7=C5=CA (errflg=3) in Unknown on line 0

( ! ) Notice: Unknown: Unexpected characters at end of address: =F3=C5=D2=C7=C5=CA (errflg=3) in Unknown on line 0

( ! ) Notice: Unknown: Unexpected characters at end of address: =F3=C5=D2=C7=C5=CA (errflg=3) in Unknown on line 0

( ! ) Notice: Unknown: Unexpected characters at end of address: =F3=C5=D2=C7=C5=CA (errflg=3) in Unknown on line 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-22 14:47 UTC] prokern at mail dot ru
Test script:
---------------
$fh	=	fopen("1.txt", "r");
$data	=	fread($fh,filesize("c:\\1.txt"));
$ob	=	imap_rfc822_parse_headers($data);
var_dump($ob);
fclose($fh);

Updated to:

$fh	=	fopen("1.txt", "r");
$data	=	fread($fh,filesize("1.txt"));
$ob	=	imap_rfc822_parse_headers($data);
var_dump($ob);
fclose($fh);

Actually, does not matter.
 [2020-10-09 14:50 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-10-09 14:50 UTC] cmb@php.net
That appears to have been fixed in the meantime, or can you still
reproduce this with any of the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2020-10-09 14:50 UTC] cmb@php.net
That appears to have been fixed in the meantime, or can you still
reproduce this with any of the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2020-10-09 14:51 UTC] cmb@php.net
BTW, the linked document exhibits an information leak.
 [2020-10-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 22:01:23 2020 UTC