From 76efd6d0637bb67b7dadf65f29a945fe2ce5fc25 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 12 Nov 2011 17:00:25 +0100 Subject: Copy all text replacements to HTML replacements in Mailer With this change it's easy to just set the replacements for HTML that need special attention. --- inc/Mailer.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index b86a9d8f2..09e457243 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -139,14 +139,22 @@ class Mailer { public function setBody($text, $textrep=null, $htmlrep=null, $html=null){ global $INFO; global $conf; + $htmlrep = (array) $htmlrep; + $textrep = (array) $textrep; // create HTML from text if not given if(is_null($html)){ $html = hsc($text); $html = nl2br($text); } - if(!is_null($textrep) && is_null($htmlrep)){ - $htmlrep = array_map('hsc',$textrep); + // copy over all replacements missing for HTML (autolink URLs) + foreach($textrep as $key => $value){ + if(isset($htmlrep[$key])) continue; + if(preg_match('/^https?:\/\//i',$value)){ + $htmlrep[$key] = ''.hsc($value).''; + }else{ + $htmlrep[$key] = hsc($value); + } } // prepare default replacements -- cgit v1.2.3