summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-08-09 09:46:54 +0000
committeralecpl <alec@alec.pl>2011-08-09 09:46:54 +0000
commit6d0ada30d7847a509db10d819020ac653597d073 (patch)
treec14e28bc4a0f0699cf4eecb87e55a80836097351 /program/include
parentefc24a5fb3d5d70e9066b1994f3b41b248e59ccd (diff)
- Fix handling of email addresses with quoted local part (#1487939)
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_imap.php7
-rw-r--r--program/include/rcube_smtp.php5
2 files changed, 8 insertions, 4 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 3ba058988..5fbf3ad54 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -4760,12 +4760,15 @@ class rcube_imap
$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 @@ class rcube_imap
// 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);
}
diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php
index 120336c49..73c30d227 100644
--- a/program/include/rcube_smtp.php
+++ b/program/include/rcube_smtp.php
@@ -439,14 +439,14 @@ class rcube_smtp
// if we're passed an array, assume addresses are valid and implode them before parsing.
if (is_array($recipients))
$recipients = implode(', ', $recipients);
-
+
$addresses = array();
$recipients = rcube_explode_quoted_string(',', $recipients);
reset($recipients);
while (list($k, $recipient) = each($recipients))
{
- $a = explode(" ", $recipient);
+ $a = rcube_explode_quoted_string(' ', $recipient);
while (list($k2, $word) = each($a))
{
if (strpos($word, "@") > 0 && $word[strlen($word)-1] != '"')
@@ -457,6 +457,7 @@ class rcube_smtp
}
}
}
+
return $addresses;
}