From 98de367c1c88cd1e269d765d270c10fc3b55553a Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 7 Oct 2009 12:23:38 -0600 Subject: [PATCH] Tweak HTML regexs For tags, need to do a non-consuming match rather than a consuming match or else attributes may not be caught at the beginning of a tag. Additionally, most browsers (except Opera) have trouble with tables set to height="100%". In these cases, the calculated height will never be proper since the table will always grow to the given height and will hide any text below it. We need to strip out these definitions (100% height for tables doesn't make much sense anyway). --- imp/lib/Mime/Viewer/Html.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index 23a9a7f16..b3626ce0a 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -45,11 +45,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html # match 1 ( # tags - ]+?src= + ]+?src= # tags - |]+?src= + |]+?src= # "background" attributes - |]+?background=|]*background=|]*background= + |]+?background=|]*background=|]*background= # "style" attributes; match 2; quotes: match 3 |(style=\s*("|\')?[^>]*?background(?:-image)?:(?(3)[^"\']|[^>])*?url\s*\() ) @@ -207,25 +207,33 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html /* Convert links to open in new windows. First we hide all * mailto: links, links that have an "#xyz" anchor and ignore * all links that already have a target. */ + $target = 'target_' . uniqid(mt_rand()); $data = preg_replace( - array('/]*\s+href=["\']?(#|mailto:))/i', - '/]*)\s+target=["\']?[^>"\'\s]*["\']?/i', + array('/]*\s+href=["\']?(#|mailto:))/i', + '/]*)\s+target=["\']?[^>"\'\s]*["\']?/i', '/]*\s+href=["\']?(#|mailto:))/i', - '/]*)\s+target=["\']?[^>"\'\s]*["\']?/i', - '/]*\s+href=["\']?(#|mailto:))/i', + '/]*)\s+target=["\']?[^>"\'\s]*["\']?/i', + '/]*)\s+height=["\']?100\%["\']?/i', 'hasMethod('mail/compose')) { $data = preg_replace_callback('/href\s*=\s*(["\'])?mailto:((?(1)[^\1]*?|[^\s>]+))(?(1)\1|)/i', array($this, '_mailtoCallback'), $data); -- 2.11.0