PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail » Bug #719

Output of MIME_RFC822::parseAddressList() wrong in some case

Details

Submitted2004-02-09 18:50 UTC
Frometienne dot goyer at linuxquebec dot com
Assignedchagenbu
StatusClosed
PackageMail
PHP Version4.3.1
OSLinux RedHat 7.3
Roadmaps(Not assigned)

Comments

[2004-02-09 18:50 UTC] etienne dot goyer at linuxquebec dot com

Description:
------------
When the 'From:' header wrap on three lines, the output of MIME_RFC822::parseAddressList() is wrong. We expect an associative array with members such as 'personnal', 'comment', etc. It output a plain, non-associative array instead.

Reproduce code:
---------------
<?php
include_once 'Mail/RFC822.php';

$headers = array('From' => '=?iso8859-1?b?Rmlyc3QtTmFtZS13aXRoLThiaXQt6enpIA==?=
=?iso8859-1?b?TGFzdC1OYW1lLVdpdGgtOGJpdC3g4OA=?=
<first-name-with-8bit.last-name-with-8bit@example.com>');

foreach ($headers as $key => $val) {
$from_arr = Mail_RFC822::parseAddressList($val, 'localhost', false);
print_r($from_arr);

}

?>

Expected result:
----------------
Array
(
[0] => stdClass Object
(
[personal] => =?iso8859-1?b?Rmlyc3QtTmFtZS13aXRoLThiaXQt6enpIA==?= =?iso8859-1?b?TGFzdC1OYW1lLVdpdGgtOGJpdC3g4OA=?=
[comment] => Array
(
)

[mailbox] => first-name-with-8bit.last-name-with-8bit
[host] => example.com
)

)

Actual result:
--------------
Array
(
[0] => =?iso8859-1?b?Rmlyc3QtTmFtZS13aXRoLThiaXQt6enpIA==?=
=?iso8859-1?b?TGFzdC1OYW1lLVdpdGgtOGJpdC3g4OA=?=
<first-name-with-8bit.last-name-with-8bit@example.com>
)

[2004-02-24 04:33 UTC] chagenbu at php dot net

This fixes the problem, for me:

// Unfold long lines.
$this->address = str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), $this->address);

(put that at line 183, at least for me, in RFC822.php - right before while ($this->address = $this->_splitAddresses($this->address)) {, etc.).

However, I'm unclear if this would have other repercussions, so I haven't committed it yet. I'd like to hear from a few people on whether or not this would break things.