From 6d0ada30d7847a509db10d819020ac653597d073 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 09 Aug 2011 05:46:54 -0400
Subject: [PATCH] - Fix handling of email addresses with quoted local part (#1487939)
---
program/include/rcube_imap.php | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 3ba0589..5fbf3ad 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -4760,12 +4760,15 @@
$str = self::explode_header_string(',;', $str, true);
$result = array();
+ // simplified regexp, supporting quoted local part
+ $email_rx = '(\S+|("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+"))@\S+';
+
foreach ($str as $key => $val) {
$name = '';
$address = '';
$val = trim($val);
- if (preg_match('/(.*)<(\S+@\S+)>$/', $val, $m)) {
+ if (preg_match('/(.*)<('.$email_rx.')>$/', $val, $m)) {
$address = $m[2];
$name = trim($m[1]);
}
@@ -4779,7 +4782,7 @@
// dequote and/or decode name
if ($name) {
- if ($name[0] == '"') {
+ if ($name[0] == '"' && $name[strlen($name)-1] == '"') {
$name = substr($name, 1, -1);
$name = stripslashes($name);
}
--
Gitblit v1.9.1