From 7f62581c10435b319806ffec786d3b8389126574 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 17 Sep 2008 03:47:32 -0400
Subject: [PATCH] - Smart Tags and NOBR tag support in html messages (#1485363, #1485327)

---
 CHANGELOG                   |    1 +
 program/steps/mail/func.inc |   11 +++++++++++
 program/lib/washtml.php     |    2 +-
 3 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 7e8bee0..35bda97 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
 - Added icons for forwarded/forwarded+replied messages (#1485257)
 - Added Reply-To to forwarded emails (#1485315)
 - Display progress message for folders create/delete/rename (#1485357)
+- Smart Tags and NOBR tag support in html messages (#1485363, #1485327)
 
 2008/09/15 (thomasb)
 ----------
diff --git a/program/lib/washtml.php b/program/lib/washtml.php
index 0cb4b20..de3b55e 100644
--- a/program/lib/washtml.php
+++ b/program/lib/washtml.php
@@ -74,7 +74,7 @@
 class washtml
 {
   /* Allowed HTML elements (default) */
-  static $html_elements = array('a', 'abbr', 'acronym', 'address', 'area', 'b', 'basefont', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'label', 'legend', 'li', 'map', 'menu', 'ol', 'p', 'pre', 'q', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'img');
+  static $html_elements = array('a', 'abbr', 'acronym', 'address', 'area', 'b', 'basefont', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'label', 'legend', 'li', 'map', 'menu', 'nobr', 'ol', 'p', 'pre', 'q', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'img');
   
   /* Ignore these HTML tags but process their content */
   static $ignore_elements = array('html', 'head', 'body');
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 7e9f0fe..3995bff 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -611,6 +611,17 @@
     // PHP bug #32547 workaround: remove title tag
     $html = preg_replace('/<title>.*<\/title>/', '', $html);
 
+    // special replacements (not properly handled by washtml class)
+    $html_search = array(
+	'/(<\/nobr>)(\s+)(<nobr>)/i',	// space(s) between <NOBR>
+	'/(<[\/]*st1:[^>]+>)/i',	// Microsoft's Smart Tags <ST1>
+    );
+    $html_replace = array(
+	'\\1'.' &nbsp; '.'\\3',
+	'',
+    );
+    $html = preg_replace($html_search, $html_replace, $html);
+
     // clean HTML with washhtml by Frederic Motte
     $wash_opts = array(
       'show_washed' => false,

--
Gitblit v1.9.1