summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc71
1 files changed, 52 insertions, 19 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 018a31b84..70441e0d7 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1383,9 +1383,6 @@ function rcmail_alter_html_link($matches)
{
global $RCMAIL;
- // Support unicode/punycode in top-level domain part
- $EMAIL_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[^&@"\'.][^@&"\']*\\.([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))';
-
$tag = strtolower($matches[1]);
$attrib = parse_attrib_string($matches[2]);
$end = '>';
@@ -1400,12 +1397,36 @@ function rcmail_alter_html_link($matches)
$attrib['href'] = $RCMAIL->url(array('task' => 'utils', 'action' => 'modcss', 'u' => $tempurl, 'c' => $GLOBALS['rcmail_html_container_id']));
$end = ' />';
}
- else if (preg_match('/^mailto:'.$EMAIL_PATTERN.'(\?[^"\'>]+)?/i', $attrib['href'], $mailto)) {
- $attrib['href'] = $mailto[0];
- $attrib['onclick'] = sprintf(
- "return %s.command('compose','%s',this)",
- JS_OBJECT_NAME,
- JQ($mailto[1].$mailto[3]));
+ else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) {
+ list($mailto, $url) = explode('?', html_entity_decode($mailto[1], ENT_QUOTES, 'UTF-8'), 2);
+
+ $url = urldecode($url);
+ $mailto = urldecode($mailto);
+ $addresses = rcube_mime::decode_address_list($mailto, null, true);
+ $mailto = array();
+
+ // do sanity checks on recipients
+ foreach ($addresses as $idx => $addr) {
+ if (rcube_utils::check_email($addr['mailto'], false)) {
+ $addresses[$idx] = $addr['mailto'];
+ $mailto[] = $addr['string'];
+ }
+ else {
+ unset($addresses[$idx]);
+ }
+ }
+
+ if (!empty($addresses)) {
+ $attrib['href'] = 'mailto:' . implode(',', $addresses);
+ $attrib['onclick'] = sprintf(
+ "return %s.command('compose','%s',this)",
+ JS_OBJECT_NAME,
+ JQ(implode(',', $mailto) . ($url ? "?$url" : '')));
+ }
+ else {
+ $attrib['href'] = '#NOP';
+ $attrib['onclick'] = '';
+ }
}
else if (empty($attrib['href']) && !$attrib['name']) {
$attrib['href'] = './#NOP';
@@ -1470,15 +1491,13 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
$mailto = rcube_idn_to_utf8($mailto);
if ($PRINT_MODE) {
- $out .= ($out ? ', ' : '') . sprintf('%s <%s>', Q($name), $mailto);
- // for printing we display all addresses
- continue;
+ $address = sprintf('%s <%s>', Q($name), Q($mailto));
}
else if ($valid) {
if ($linked) {
$attrs = array(
'href' => 'mailto:' . $mailto,
- 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($mailto)),
+ 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ(format_email_recipient($mailto, $name))),
'class' => "rcmContactAddress",
);
@@ -1536,6 +1555,15 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
}
if ($moreadrs) {
+ if ($PRINT_MODE) {
+ $out .= ' ' . html::a(array(
+ 'href' => '#more',
+ 'class' => 'morelink',
+ 'onclick' => '$(this).hide().next().show()',
+ ), Q(rcube_label(array('name' => 'andnmore', 'vars' => array('nr' => $moreadrs))))) .
+ html::span(array('style' => 'display:none'), join(', ', $allvalues));
+ }
+ else {
$out .= ' ' . html::a(array(
'href' => '#more',
'class' => 'morelink',
@@ -1545,6 +1573,7 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
JQ($title))
),
Q(rcube_label(array('name' => 'andnmore', 'vars' => array('nr' => $moreadrs)))));
+ }
}
return $out;
@@ -1730,7 +1759,7 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
$a_to = rcube_mime::decode_address_list($MESSAGE->headers->to, null, true, $MESSAGE->headers->charset);
foreach ($a_to as $addr) {
if (!empty($addr['mailto'])) {
- $a_recipients[] = format_email($addr['mailto']);
+ $a_recipients[] = strtolower($addr['mailto']);
$a_names[] = $addr['name'];
}
}
@@ -1739,7 +1768,7 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
$a_cc = rcube_mime::decode_address_list($MESSAGE->headers->cc, null, true, $MESSAGE->headers->charset);
foreach ($a_cc as $addr) {
if (!empty($addr['mailto'])) {
- $a_recipients[] = format_email($addr['mailto']);
+ $a_recipients[] = strtolower($addr['mailto']);
$a_names[] = $addr['name'];
}
}
@@ -1765,7 +1794,7 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
break;
}
// use replied message recipients
- else if (($found = array_search($ident['email_ascii'], $a_recipients)) !== false) {
+ else if (($found = array_search(strtolower($ident['email_ascii']), $a_recipients)) !== false) {
if ($found_idx === null) {
$found_idx = $idx;
}
@@ -1784,15 +1813,19 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
// Try Return-Path
if ($from_idx === null && ($return_path = $MESSAGE->headers->others['return-path'])) {
+ $return_path = array_map('strtolower', (array) $return_path);
+
foreach ($identities as $idx => $ident) {
// Return-Path header contains an email address, but on some mailing list
// it can be e.g. <pear-dev-return-55250-local=domain.tld@lists.php.net>
// where local@domain.tld is the address we're looking for (#1489241)
- $ident1 = $ident['email_ascii'];
+ $ident1 = strtolower($ident['email_ascii']);
$ident2 = str_replace('@', '=', $ident1);
+ $ident1 = '<' . $ident1 . '>';
+ $ident2 = '-' . $ident2 . '@';
- foreach ((array)$return_path as $path) {
- if (stripos($path, $ident1) !== false || stripos($path, $ident2)) {
+ foreach ($return_path as $path) {
+ if ($path == $ident1 || stripos($path, $ident2)) {
$from_idx = $idx;
break 2;
}