Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0

Bug #719 Output of MIME_RFC822::parseAddressList() wrong in some case
Submitted: 2004-02-09 18:50 UTC
From: etienne dot goyer at linuxquebec dot com Assigned: chagenbu
Status: Closed Package: Mail
PHP Version: 4.3.1 OS: Linux RedHat 7.3
Roadmaps: (Not assigned)    
Subscription  


 [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> )

Comments

 [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.
 [2004-12-22 00:48 UTC] justinpatrin
It looks like the RFC defines end-of-line to be CRLF. It states that CRLF followed by whitespace should be "unfolded" by removing the CRLF. Upon further looking, Mail/mimiDecode.php uses this to break up headers (given the entire header block): $input = preg_replace("/\r?\n/", "\r\n", $input); $input = preg_replace("/\r\n(\t| )+/", ' ', $input); $headers = explode("\r\n", trim($input)); So it fixes possibly bad newlines, replaces CRLF followed by a tab or space by a space, then breaks them up. I suggest you use something similar to this (or those exact preg_replace calls) as it follows the RFC correctly AFAIK.
 [2004-12-27 17:04 UTC] chagenbu
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 pear.php.net. In case this was a pear.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 PEAR better.