cvs: php4 /pear/Mail RFC822.php

From: Date: Thu, 28 Jun 2001 14:53:35 +0000
Subject: cvs: php4 /pear/Mail RFC822.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-195@lists.php.net to get a copy of this message
chagenbu Thu Jun 28 10:53:35 2001 EDT Modified files: /php4/pear/Mail RFC822.php Log: support () comments (Nic Bernstein <nic@mailbox.itech-mke.com>) Index: php4/pear/Mail/RFC822.php diff -u php4/pear/Mail/RFC822.php:1.6 php4/pear/Mail/RFC822.php:1.7 --- php4/pear/Mail/RFC822.php:1.6 Thu Mar 29 15:11:36 2001 +++ php4/pear/Mail/RFC822.php Thu Jun 28 10:53:32 2001 @@ -22,7 +22,7 @@ * * @author Richard Heyes <richard.heyes@heyes-computing.net> * @author Chuck Hagenbuch <chuck@horde.org> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class Mail_RFC822 { @@ -272,6 +272,7 @@ if ($this->hasUnclosedQuotes($string) || $this->hasUnclosedBrackets($string, '<>') || $this->hasUnclosedBrackets($string, '[]') + || $this->hasUnclosedBrackets($string, '()') || substr($string, -1) == '\\') { if (isset($parts[$i + 1])) { $string = $string . $char . $parts[$i + 1]; @@ -543,6 +544,17 @@ // A couple of defaults. $phrase = ''; + // Catch any RFC822 comments and store them separately + ereg("\(.*\)", $mailbox, $regs); + if(is_array($regs)) { + foreach($regs as $string) { + $mailbox = str_replace($string, ' ', $mailbox); + $comment .= substr($string, 1, -1); + } + $mailbox = trim($mailbox); + $comment = trim($comment); + } + // Check for name + route-addr if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { $parts = explode('<', $mailbox); @@ -568,7 +580,18 @@ // Construct the object that will be returned. $mbox = new stdClass(); - $phrase !== '' ? $mbox->personal = $phrase : ''; + + // If we have a phrase, use that as personal, else use comment + if (trim($phrase) == '') { + if (trim($comment) == '') { + $mbox->personal = ''; + } else { + $mbox->personal = $comment; + } + } else { + $mbox->personal = $phrase; + $mbox->comment = $comment; + } if (isset($route_addr)) { $mbox->mailbox = $route_addr['local_part'];

« previous php.pear.cvs (#195) next »