- Fix decoding of e-mail address strings in message headers (#1487068)

release-0.6
alecpl 14 years ago
parent 13326b7540
commit 435c315223

@ -35,6 +35,7 @@ CHANGELOG Roundcube Webmail
- Add ACL extension support into IMAP classes (RFC4314) - Add ACL extension support into IMAP classes (RFC4314)
- Add ANNOTATEMORE extension support into IMAP classes (draft-daboo-imap-annotatemore) - Add ANNOTATEMORE extension support into IMAP classes (draft-daboo-imap-annotatemore)
- Add METADATA extension support into IMAP classes (RFC5464) - Add METADATA extension support into IMAP classes (RFC5464)
- Fix decoding of e-mail address strings in message headers (#1487068)
RELEASE 0.4.2 RELEASE 0.4.2
------------- -------------

@ -4000,10 +4000,7 @@ class rcube_imap
foreach ($a as $val) { foreach ($a as $val) {
$j++; $j++;
$address = trim($val['address']); $address = trim($val['address']);
$name = trim($val['name']); $name = trim($val['name']);
if ($name && preg_match('/^[\'"]/', $name) && preg_match('/[\'"]$/', $name))
$name = trim($name, '\'"');
if ($name && $address && $name != $address) if ($name && $address && $name != $address)
$string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
@ -4419,22 +4416,40 @@ class rcube_imap
$result = array(); $result = array();
foreach ($a as $key => $val) { foreach ($a as $key => $val) {
$val = preg_replace("/([\"\w])</", "$1 <", $val); $name = '';
$sub_a = rcube_explode_quoted_string(' ', $decode ? $this->decode_header($val) : $val); $address = '';
$result[$key]['name'] = ''; $val = trim($val);
foreach ($sub_a as $k => $v) { if (preg_match('/(.*)<(\S+@\S+)>$/', $val, $m)) {
// use angle brackets in regexp to not handle names with @ sign $address = $m[2];
if (preg_match('/^<\S+@\S+>$/', $v)) $name = trim($m[1]);
$result[$key]['address'] = trim($v, '<>'); }
else else if (preg_match('/^(\S+@\S+)$/', $val, $m)) {
$result[$key]['name'] .= (empty($result[$key]['name'])?'':' ').str_replace("\"",'',stripslashes($v)); $address = $m[1];
$name = '';
}
else {
$name = $val;
} }
// if (empty($result[$key]['name'])) // dequote and/or decode name
// $result[$key]['name'] = $result[$key]['address']; if ($name) {
if (empty($result[$key]['address'])) if ($name[0] == '"') {
$result[$key]['address'] = $result[$key]['name']; $name = substr($name, 1, -1);
$name = stripslashes($name);
}
else if ($decode) {
$name = $this->decode_header($name);
}
}
if (!$address && $name) {
$address = $name;
}
if ($address) {
$result[$key] = array('name' => $name, 'address' => $address);
}
} }
return $result; return $result;

Loading…
Cancel
Save