From: Michael M Slusarz Date: Fri, 25 Sep 2009 17:10:08 +0000 (-0600) Subject: Move phishing highlighting CSS into driver (needed since output might be in an IFRAME... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=55eb7f73ef265df5f01287c94423002a14ca001a;p=horde.git Move phishing highlighting CSS into driver (needed since output might be in an IFRAME; Add 'phishing' parameter --- diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Html.php b/framework/Mime/lib/Horde/Mime/Viewer/Html.php index d5e5d6e1e..c923e20a5 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Html.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Html.php @@ -29,6 +29,13 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver ); /** + * The CSS used to display the phishing warning. + * + * @var string + */ + protected $_phishCss = 'padding: 1px;margin-bottom: 3px;font-size: 90%;border: 1px solid #800;background: #e81222;color: #fff;width: 100%;'; + + /** * Phishing status of last call to _phishingCheck(). * * @var boolean @@ -81,10 +88,13 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver * @param string $data The HTML data. * @param array $options Additional options: *
-     * 'charset' => (string) The charset of $data (if different than the base
-     *              part charset).
+     * 'charset' => (string) The charset of $data.
+     *              DEFAULT: The base part charset.
      * 'inline' => (boolean) Are we viewing inline?
      *             DEFAULT: false
+     * 'phishing' => (boolean) Do phishing highlighting even if not viewing
+     *               inline.
+     *               DEFAULT: false.
      * 
* * @return string The cleaned HTML string. @@ -136,7 +146,7 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver )); /* Check for phishing exploits. */ - if (!empty($options['inline'])) { + if (!empty($options['inline']) || !empty($options['phishing'])) { $data = $this->_phishingCheck($data); } @@ -179,7 +189,7 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver * text has the same IP address. */ if (!isset($m[3]) || ($m[2] != $m[3])) { if (isset($m[3]) && !$scanonly) { - $data = preg_replace('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/' . preg_quote($m[2], '/') . '(?:[^>]*>\s*(?:$1:\/\/)?' . preg_quote($m[3], '/') . '[^<]*<\/a)?/i', 'class="mimeStatusWarning" $0', $data); + $data = preg_replace('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/' . preg_quote($m[2], '/') . '(?:[^>]*>\s*(?:$1:\/\/)?' . preg_quote($m[3], '/') . '[^<]*<\/a)?/i', 'style="' . $this->_phishCss . '" $0', $data); } $this->_phishWarn = true; } @@ -202,7 +212,7 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver if (!(count($host1) && count($host2)) || (strcasecmp($host1[1], $host2[1]) !== 0)) { if (!$scanonly) { - $data = preg_replace('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/' . preg_quote($m[1][$i], '/') . '["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?' . preg_quote($m[2][$i], '/') . '<\/a/is', 'class="mimeStatusWarning" $0', $data); + $data = preg_replace('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/' . preg_quote($m[1][$i], '/') . '["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?' . preg_quote($m[2][$i], '/') . '<\/a/is', 'style="' . $this->_phishCss . '" $0', $data); } $this->_phishWarn = true; } @@ -228,7 +238,7 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver 'class' => 'mimestatuswarning', 'text' => array( sprintf(_("%s: This message may not be from whom it claims to be. Beware of following any links in it or of providing the sender with any personal information."), _("Warning")), - _("The links that caused this warning have this background color:") . ' ' . _("EXAMPLE") . '.' + _("The links that caused this warning have this background color:") . ' ' . _("EXAMPLE") . '.' ) ); }