From d25c6e538b123155e705d134b1d5c1e768c48ff9 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Fri, 31 Jan 2014 16:41:40 +0000 Subject: [PATCH] Remove quoted response removal - it's now handled at the email parsing level. Handle cases where thready body is sent in as a string We're going to assume HTML of html thread is enabled - otherwise text is assumed. --- include/class.thread.php | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index c77a5f4b6..f0f6b1c78 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -865,28 +865,15 @@ Class ThreadEntry { if(!$vars['ticketId'] || !$vars['type'] || !in_array($vars['type'], array('M','R','N'))) return false; - //Strip quoted reply...on emailed messages - if($vars['origin'] - && !strcasecmp($vars['origin'], 'Email') - && $cfg->stripQuotedReply() - && ($tag=$cfg->getReplySeparator()) - && strpos($vars['body'], $tag)) - // TODO: Move this to the ThreadBody class - if((list($msg) = explode($tag, $vars['body'], 2)) && trim($msg)) - $vars['body'] = $msg; - - if ($vars['body'] instanceof ThreadBody) { - $vars['body'] = $vars['body']->convertTo('html'); - } - elseif (!$cfg->isHtmlThreadEnabled()) { - // Data in the database is assumed to be HTML, change special - // plain text XML characters - // XXX: Why isn't `title` always scrubbed? - $vars['title'] = Format::htmlchars($vars['title']); - $vars['body'] = sprintf('<pre>%s</pre>', - Format::htmlchars($vars['body'])); + + if (!$vars['body'] instanceof ThreadBody) { + if ($cfg->isHtmlThreadEnabled()) + $vars['body'] = new HtmlThreadBody($vars['body']); + else + $vars['body'] = new TextThreadBody($vars['body']); } - $vars['body'] = Format::sanitize($vars['body']); + + $body = Format::sanitize((string) $vars['body']->convertTo('html')); $poster = $vars['poster']; if ($poster && is_object($poster)) @@ -904,7 +891,7 @@ Class ThreadEntry { if (!isset($vars['attachments']) || !$vars['attachments']) // Otherwise, body will be configured in a block below (after // inline attachments are saved and updated in the database) - $sql.=' ,body='.db_input($vars['body']); + $sql.=' ,body='.db_input($body); if(isset($vars['pid'])) $sql.=' ,pid='.db_input($vars['pid']); @@ -941,12 +928,12 @@ Class ThreadEntry { // content-id will be discarded, only the unique hash-code // will be available to retrieve the image later if ($a['cid'] && $a['key']) { - $vars['body'] = str_replace('src="cid:'.$a['cid'].'"', - 'src="cid:'.$a['key'].'"', $vars['body']); + $body = str_replace('src="cid:'.$a['cid'].'"', + 'src="cid:'.$a['key'].'"', $body); } } unset($a); - $sql = 'UPDATE '.TICKET_THREAD_TABLE.' SET body='.db_input($vars['body']) + $sql = 'UPDATE '.TICKET_THREAD_TABLE.' SET body='.db_input($body) .' WHERE `id`='.db_input($entry->getId()); if (!db_query($sql) || !db_affected_rows()) return false; @@ -959,7 +946,7 @@ Class ThreadEntry { $entry->saveEmailInfo($vars); // Inline images (attached to the draft) - $entry->saveAttachments(Draft::getAttachmentIds($vars['body'])); + $entry->saveAttachments(Draft::getAttachmentIds($body)); return $entry; } -- GitLab