From f76ced577d8c58b1396f9b2111d632dcbb4e926d Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Wed, 23 Oct 2013 13:37:43 +0000 Subject: [PATCH] User html2html wrapper --- include/ajax.kbase.php | 4 ++-- include/class.format.php | 3 ++- include/class.mailer.php | 4 ++-- include/class.mailfetch.php | 2 +- include/class.mailparse.php | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/ajax.kbase.php b/include/ajax.kbase.php index ba0cf1d1c..d6d30a1b0 100644 --- a/include/ajax.kbase.php +++ b/include/ajax.kbase.php @@ -42,7 +42,7 @@ class KbaseAjaxAPI extends AjaxController { $resp['files'] = $canned->attachments->getSeparates(); if (!$cfg->isHtmlThreadEnabled()) { - $resp['response'] = convert_html_to_text($resp['response'], 90); + $resp['response'] = Format::html2text($resp['response'], 90); $resp['files'] += $canned->attachments->getInlines(); } @@ -54,7 +54,7 @@ class KbaseAjaxAPI extends AjaxController { $response =$ticket?$ticket->replaceVars($canned->getResponse()):$canned->getResponse(); if (!$cfg->isHtmlThreadEnabled()) - $response = convert_html_to_text($response, 90); + $response = Format::html2text($response, 90); } return $response; diff --git a/include/class.format.php b/include/class.format.php index d8463ec51..f86982a38 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -137,7 +137,8 @@ class Format { return htmLawed($html, $config); } - function html2text($html, $width=74) { + function html2text($html, $width=74, $tidy=true) { + # Tidy html: decode, balance, sanitize tags if($tidy) diff --git a/include/class.mailer.php b/include/class.mailer.php index e13eff86e..61dda2c00 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -143,8 +143,8 @@ class Mailer { if (!(isset($options['text']) && $options['text']) && preg_match('/^\s*</', $message)) { // Make sure nothing unsafe has creeped into the message - $message = Format::safe_html($message); - $mime->setTXTBody(convert_html_to_text($message)); + $message = Format::safe_html($message); //XXX?? + $mime->setTXTBody(Format::html2text($message), 90, false); } else { $mime->setTXTBody($message); diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index d270f0140..f71c00251 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -441,7 +441,7 @@ class MailFetcher { $body = Format::htmlchars($body); } elseif ($body=$this->getPart($mid, 'text/html', $this->charset)) { - $body = convert_html_to_text(Format::safe_html($body), 100); + $body = Format::html2text(Format::safe_html($body), 100, false); } $body = trim($body) ? sprintf('<div style="white-space:pre-wrap">%s</div>', diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 2438d4f4d..08e2f92b0 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -191,7 +191,7 @@ class Mail_Parse { $body = Format::htmlchars($body); } elseif ($body=$this->getPart($this->struct,'text/html')) { - $body = convert_html_to_text($body, 100); + $body = Format::html2text(Format::safe_html($body), 100, false); } $body = trim($body) ? sprintf('<div style="white-space:pre-wrap">%s</div>', -- GitLab