diff options
-rw-r--r-- | includes/mail.inc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/includes/mail.inc b/includes/mail.inc index 72c7258e6..4234aacab 100644 --- a/includes/mail.inc +++ b/includes/mail.inc @@ -276,6 +276,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) { // Replace inline <a> tags with the text of link and a footnote. // 'See <a href="http://drupal.org">the Drupal site</a>' becomes // 'See the Drupal site [1]' with the URL included as a footnote. + _drupal_html_to_mail_urls(NULL, TRUE); $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i'; $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string); $urls = _drupal_html_to_mail_urls(); @@ -429,17 +430,24 @@ function _drupal_wrap_mail_line(&$line, $key, $values) { * * Keeps track of URLs and replaces them with placeholder tokens. */ -function _drupal_html_to_mail_urls($match = NULL) { +function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) { global $base_url, $base_path; static $urls = array(), $regexp; - if (empty($regexp)) { - $regexp = '@^'. preg_quote($base_path, '@') .'@'; + + if ($reset) { + // Reset internal URL list. + $urls = array(); } - if ($match) { - list(, , $url, $label) = $match; - // Ensure all URLs are absolute. - $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url); - return $label .' ['. count($urls) .']'; + else { + if (empty($regexp)) { + $regexp = '@^'. preg_quote($base_path, '@') .'@'; + } + if ($match) { + list(, , $url, $label) = $match; + // Ensure all URLs are absolute. + $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url); + return $label .' ['. count($urls) .']'; + } } return $urls; } |