From 1e8a8e1c7d1168063a23c67f389678085a6d9881 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sat, 24 Jul 2010 12:47:22 -0600 Subject: [PATCH] More HTML viewer tweaking --- imp/lib/Mime/Viewer/Html.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index 489b80749..81a0763bd 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -159,6 +159,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html 'noprefetch' => ($inline && ($_SESSION['imp']['view'] != 'mimp')), 'phishing' => $inline )); + $status = array(); if ($this->_phishWarn) { $status[] = array( @@ -326,11 +327,27 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html break; } - if ($this->_imptmp['img'] && $node->hasAttribute('style')) { - $this->_imptmp['node'] = $node; - $style = preg_replace_callback('/(background(?:-image)?:[^;\}]*(?:url\(["\']?))(.*?)((?:["\']?\)))/i', array($this, '_styleCallback'), $node->getAttribute('style'), -1, $matches); - if ($matches) { - $node->setAttribute('style', $style); + + if (!is_null($this->_imptmp)) { + $remove = array(); + foreach ($node->attributes as $val) { + /* Catch random mailto: strings in attributes that will + * cause problems with e-mail linking. */ + if (stripos($val->value, 'mailto:') === 0) { + $remove[] = $val->name; + } + } + + foreach ($remove as $val) { + $node->removeAttribute($val); + } + + if ($this->_imptmp['img'] && $node->hasAttribute('style')) { + $this->_imptmp['node'] = $node; + $style = preg_replace_callback('/(background(?:-image)?:[^;\}]*(?:url\(["\']?))(.*?)((?:["\']?\)))/i', array($this, '_styleCallback'), $node->getAttribute('style'), -1, $matches); + if ($matches) { + $node->setAttribute('style', $style); + } } } } -- 2.11.0