summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-03-21 13:29:12 +0000
committerthomascube <thomas@roundcube.net>2008-03-21 13:29:12 +0000
commit0c6f4b88648879cf12342d16c83bdd0d3a11672f (patch)
tree4f3b1180e4c9886abfddec7e5dc2d9fa890e8a52 /program/include
parent46bc52b56a3201fc3e1aa687eb99725d8e26b37a (diff)
Better patch to correctly quote email recipient strings (from #1484191)
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc5
-rw-r--r--program/include/rcube_imap.inc4
2 files changed, 7 insertions, 2 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 3a1d64734..cb25fbd77 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1567,7 +1567,10 @@ function format_date($date, $format=NULL)
function format_email_recipient($email, $name='')
{
if ($name && $name != $email)
- return sprintf('%s <%s>', strpos($name, ",") ? '"'.$name.'"' : $name, $email);
+ {
+ // Special chars as defined by RFC 822 need to in quoted string (or escaped).
+ return sprintf('%s <%s>', preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, $email);
+ }
else
return $email;
}
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 170e4a565..5b3efb80f 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -2272,6 +2272,8 @@ class rcube_imap
{
$a = $this->_parse_address_list($input, $decode);
$out = array();
+ // Special chars as defined by RFC 822 need to in quoted string (or escaped).
+ $special_chars = '[\(\)\<\>\\\.\[\]@,;:"]';
if (!is_array($a))
return $out;
@@ -2285,7 +2287,7 @@ class rcube_imap
$address = $val['address'];
$name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', trim($val['name']));
if ($name && $address && $name != $address)
- $string = sprintf('%s <%s>', preg_match('/[,;<>]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
+ $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
else if ($address)
$string = $address;
else if ($name)