php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56853 problem with multiple headers with the same name
Submitted: 2006-02-21 15:50 UTC Modified: 2008-01-08 15:07 UTC
From: dominik at rangers dot eu dot org Assigned:
Status: Closed Package: mailparse (PECL)
PHP Version: 5.0.4 OS: Linux / Fedora Core 4
Private report: No CVE-ID: None
 [2006-02-21 15:50 UTC] dominik at rangers dot eu dot org
Description:
------------
mailparse 2.1.1

When parsing an e-mail where there are multiple headers with the same name, e.g. multiple Received: headers, only the last one remains in the data structure returned by mailparse_msg_get_part_data($section). All others are lost, because it's a string and not an array. For now I'm using PEAR/Mail/mimeDecode.php, which does return an array if multiple headers with the same name are found, but it's much slower. I'd appreciate it if you could fix this quickly.

Reproduce code:
---------------
$msg = <<<EOD
Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
         Sat, 18 Feb 2006 22:58:14 -0800
Received: from 66.178.40.49 by BAY116-DAV8.phx.gbl with DAV;
        Sun, 19 Feb 2006 06:58:13 +0000

test
EOD;

$mail = mailparse_msg_create();
mailparse_msg_parse($mail,$msg);
$struct = mailparse_msg_get_structure($mail);

foreach($struct as $st) {
	$section = mailparse_msg_get_part($mail, $st);
	$info = mailparse_msg_get_part_data($section);
	echo "<pre>\n";
	var_dump($info);
	echo "</pre>\n";
}


Expected result:
----------------
array(11) {
  ["headers"]=>
  array(1) {
    ["received"]=>
    array(2) {
      [0]=>
      string(95) "from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 18 Feb 2006 22:58:14 -0800"
      [1]=>
      string(82) "from 66.178.40.49 by BAY116-DAV8.phx.gbl with DAV; Sun, 19 Feb 2006 06:58:13 +0000"
  }
  ["starting-pos"]=>
  int(0)
...
}

Actual result:
--------------
array(11) {
  ["headers"]=>
  array(1) {
    ["received"]=>
    string(90) "from 66.178.40.49 by BAY116-DAV8.phx.gbl with DAV;         Sun, 19 Feb 2006 06:58:13 +0000"
  }
  ["starting-pos"]=>
  int(0)
...
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-21 15:52 UTC] dominik at rangers dot eu dot org
Oops, I didn't notice it does return an array for Received: headers, but still, it's a one-element array, so the result is still wrong.
 [2006-02-21 15:53 UTC] dominik at rangers dot eu dot org
Hm... disregard my last comment.
 [2007-04-03 09:20 UTC] barns at uk dot umis dot net
I too, have experienced this problem.

with versions 2.1.1.

I am using freebsd 6.1R with apache 2.2.2 and PHP 5.1.4.

I am using this with atmail's php version 5.. i have switched to the pear mimeDecode and all works fine.


Regards
Barnaby
 [2008-01-08 15:07 UTC] shire@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC