Aleksander Machniak
2013-03-19 1e32540839683c1309db012c4d5b9aff35ec6ae3
program/steps/mail/func.inc
@@ -760,7 +760,8 @@
  global $RCMAIL;
  // make links and email-addresses clickable
  $replacer = new rcmail_string_replacer;
  $attribs  = array('link_attribs' => array('rel' => 'noreferrer', 'target' => '_blank'));
  $replacer = new rcmail_string_replacer($attribs);
  // search for patterns like links and e-mail addresses and replace with tokens
  $body = $replacer->replace($body);
@@ -1373,7 +1374,7 @@
/**
 * parse link attributes and set correct target
 * parse link (a, link, area) attributes and set correct target
 */
function rcmail_alter_html_link($matches)
{
@@ -1382,9 +1383,9 @@
  // 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 = $matches[1];
  $tag    = strtolower($matches[1]);
  $attrib = parse_attrib_string($matches[2]);
  $end = '>';
  $end    = '>';
  // Remove non-printable characters in URL (#1487805)
  if ($attrib['href'])
@@ -1411,6 +1412,11 @@
    $attrib['target'] = '_blank';
  }
  // Better security by adding rel="noreferrer" (#1484686)
  if (($tag == 'a' || $tag == 'area') && $attrib['href'] && $attrib['href'][0] != '#') {
    $attrib['rel'] = 'noreferrer';
  }
  // allowed attributes for a|link|area tags
  $allow = array('href','name','target','onclick','id','class','style','title',
    'rel','type','media','alt','coords','nohref','hreflang','shape');