X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fmessage.inc.php;fp=banana%2Fmessage.inc.php;h=357c26a3ea860959b9dee51acbb83e394fc5dd06;hb=16800641247adf482c6a8bc3b60707eac2bfe345;hp=da5b05c7fd2f4550272152644e59458223ae9d4f;hpb=8575148f767c35d84122edf39f9a416010d9e532;p=banana.git diff --git a/banana/message.inc.php b/banana/message.inc.php index da5b05c..357c26a 100644 --- a/banana/message.inc.php +++ b/banana/message.inc.php @@ -142,30 +142,33 @@ final class BananaMessage extends BananaMimePart return array_merge($headers, parent::getHeaders()); } - static public function formatFrom($text, $subject = '') + static public function extractMail($text) { -# From: mark@cbosgd.ATT.COM -# From: -# From: mark@cbosgd.ATT.COM (Mark Horton) -# From: Mark Horton - $mailto = ' ]+)>?$/", $text, $regs)) { - $result = $mailto . $regs[1] . $subject . '">' . banana_htmlentities($regs[1]) . ''; - } - if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $text, $regs)) { - $result = $mailto . $regs[1] . $subject . '">' . banana_htmlentities($regs[2]) . ''; - } if (preg_match("/^\"?([^<>\"]+)\"? +<(.+@.+)>$/", $text, $regs)) { + # From: Mark Horton $nom = preg_replace("/^'(.*)'$/", '\1', $regs[1]); $nom = stripslashes($nom); - $result = $mailto . $regs[2] . $subject . '">' . banana_htmlentities($nom) . ''; + return array($nom, strtolower($regs[2])); + } else if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $text, $regs)) { + # From: mark@cbosgd.ATT.COM (Mark Horton) + return array($regs[2], strtolower($regs[1])); + } else if (preg_match("/^ ]+)>?$/", $text, $regs)) { + # From: + return array($regs[1], strtolower($regs[1])); + } else { + # From: mark@cbosgd.ATT.COM + return array($text, strtolower($text)); + } + } + + static public function formatFrom($text, $subject = '') + { + list($name, $email) = self::extractMail($text); + if ($subject) { + $subject = '?subject=' . banana_htmlentities(_b_('Re: ') . $subject, ENT_QUOTES); } - return preg_replace("/\\\(\(|\))/","\\1",$result); + $result = '' . banana_htmlentities($name) . ''; + return preg_replace("/\\\(\(|\))/","\\1", $result); } public function getAuthorName()