From 6522478618e7c5353dcfa8d06ce37c5eb6034714 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 25 Oct 2013 21:42:44 +0000 Subject: [PATCH] Use <pre> elements for text emails This provides better compatibility with mPDF, which doesn't support the CSS white-space:pre-wrap property --- include/class.format.php | 4 +--- include/class.mailfetch.php | 4 ++-- include/class.mailparse.php | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/class.format.php b/include/class.format.php index fd51d9586..4ed82d907 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -168,6 +168,7 @@ class Format { 'safe' => 1, //Exclude applet, embed, iframe, object and script tags. 'balance' => 1, //balance and close unclosed tags. 'comment' => 1, //Remove html comments (OUTLOOK LOVE THEM) + 'tidy' => -1, 'deny_attribute' => 'id', 'schemes' => 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https; src: cid, http, https, data', 'hook_tag' => function ($el, $attributes=0) { @@ -196,9 +197,6 @@ class Format { } ); - if (!preg_match('/style="[^"]*white-space:\s*pre/i', $html) !== false) - $config['tidy'] = -1; // Clean extra whitspace - return Format::html($html, $config); } diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index f71c00251..0f1f7cef5 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -431,7 +431,7 @@ class MailFetcher { } elseif ($body=$this->getPart($mid, 'text/plain', $this->charset)) { $body = trim($body) - ? sprintf('<div style="white-space:pre-wrap">%s</div>', + ? sprintf('<pre>%s</pre>', Format::htmlchars($body)) : '--'; } @@ -444,7 +444,7 @@ class MailFetcher { $body = Format::html2text(Format::safe_html($body), 100, false); } $body = trim($body) - ? sprintf('<div style="white-space:pre-wrap">%s</div>', + ? sprintf('<pre>%s</pre>', $body) : '--'; } diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 15247689c..8d84f3f5a 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -181,7 +181,7 @@ class Mail_Parse { } elseif ($body=$this->getPart($this->struct,'text/plain')) { $body = trim($body) - ? sprintf('<div style="white-space:pre-wrap">%s</div>', + ? sprintf('<pre>%s</pre>', Format::htmlchars($body)) : '--'; } @@ -194,7 +194,7 @@ class Mail_Parse { $body = Format::html2text(Format::safe_html($body), 100, false); } $body = trim($body) - ? sprintf('<div style="white-space:pre-wrap">%s</div>', + ? sprintf('<pre>%s</pre>', $body) : '--'; } -- GitLab