Use Delivered-To header as a last resort for identity selection (#1488840)

pull/49/merge
Aleksander Machniak 12 years ago
parent 511e1668e6
commit 30cc01f89d

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Use Delivered-To header as a last resort for identity selection (#1488840)
- Fix XSS vulnerability using Flash files (#1488828) - Fix XSS vulnerability using Flash files (#1488828)
- Fix absolute positioning in HTML messages (#1488819) - Fix absolute positioning in HTML messages (#1488819)
- Fix cache (in)validation after setting \Deleted flag - Fix cache (in)validation after setting \Deleted flag

@ -2206,18 +2206,20 @@ class rcube_imap_generic
} }
break; break;
default: default:
if (strlen($field) > 2) { if (strlen($field) < 3) {
$result[$id]->others[$field] = $string;
}
break; break;
} }
if ($result[$id]->others[$field]) {
$string = array_merge((array)$result[$id]->others[$field], (array)$string);
}
$result[$id]->others[$field] = $string;
}
} }
} }
} }
// VANISHED response (QRESYNC RFC5162) // VANISHED response (QRESYNC RFC5162)
// Sample: * VANISHED (EARLIER) 300:310,405,411 // Sample: * VANISHED (EARLIER) 300:310,405,411
else if (preg_match('/^\* VANISHED [()EARLIER]*/i', $line, $match)) { else if (preg_match('/^\* VANISHED [()EARLIER]*/i', $line, $match)) {
$line = substr($line, strlen($match[0])); $line = substr($line, strlen($match[0]));
$v_data = $this->tokenizeResponse($line, 1); $v_data = $this->tokenizeResponse($line, 1);

@ -64,6 +64,7 @@ abstract class rcube_storage
'MAIL-FOLLOWUP-TO', 'MAIL-FOLLOWUP-TO',
'MAIL-REPLY-TO', 'MAIL-REPLY-TO',
'RETURN-PATH', 'RETURN-PATH',
'DELIVERED-TO',
); );
const UNKNOWN = 0; const UNKNOWN = 0;

@ -298,7 +298,6 @@ else if (count($MESSAGE->identities)) {
$from_idx = null; $from_idx = null;
$found_idx = null; $found_idx = null;
$default_identity = 0; // default identity is always first on the list $default_identity = 0; // default identity is always first on the list
$return_path = $MESSAGE->headers->others['return-path'];
// Select identity // Select identity
foreach ($MESSAGE->identities as $idx => $ident) { foreach ($MESSAGE->identities as $idx => $ident) {
@ -332,8 +331,8 @@ else if (count($MESSAGE->identities)) {
$from_idx = $found_idx; $from_idx = $found_idx;
} }
// Fallback using Return-Path // Try Return-Path
if ($from_idx === null && $return_path) { if ($from_idx === null && ($return_path = $MESSAGE->headers->others['return-path'])) {
foreach ($MESSAGE->identities as $idx => $ident) { foreach ($MESSAGE->identities as $idx => $ident) {
if (strpos($return_path, str_replace('@', '=', $ident['email_ascii']).'@') !== false) { if (strpos($return_path, str_replace('@', '=', $ident['email_ascii']).'@') !== false) {
$from_idx = $idx; $from_idx = $idx;
@ -342,6 +341,16 @@ else if (count($MESSAGE->identities)) {
} }
} }
// Fallback using Delivered-To
if ($from_idx === null && ($delivered_to = $MESSAGE->headers->others['delivered-to'])) {
foreach ($MESSAGE->identities as $idx => $ident) {
if (in_array($ident['email_ascii'], $delivered_to)) {
$from_idx = $idx;
break;
}
}
}
$ident = $MESSAGE->identities[$from_idx !== null ? $from_idx : $default_identity]; $ident = $MESSAGE->identities[$from_idx !== null ? $from_idx : $default_identity];
$from_id = $ident['identity_id']; $from_id = $ident['identity_id'];

Loading…
Cancel
Save