Skip to content
Snippets Groups Projects
Commit d25c6e53 authored by Peter Rotich's avatar Peter Rotich
Browse files

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.
parent 80b4917a
No related branches found
No related tags found
No related merge requests found
...@@ -865,28 +865,15 @@ Class ThreadEntry { ...@@ -865,28 +865,15 @@ Class ThreadEntry {
if(!$vars['ticketId'] || !$vars['type'] || !in_array($vars['type'], array('M','R','N'))) if(!$vars['ticketId'] || !$vars['type'] || !in_array($vars['type'], array('M','R','N')))
return false; return false;
//Strip quoted reply...on emailed messages
if($vars['origin'] if (!$vars['body'] instanceof ThreadBody) {
&& !strcasecmp($vars['origin'], 'Email') if ($cfg->isHtmlThreadEnabled())
&& $cfg->stripQuotedReply() $vars['body'] = new HtmlThreadBody($vars['body']);
&& ($tag=$cfg->getReplySeparator()) else
&& strpos($vars['body'], $tag)) $vars['body'] = new TextThreadBody($vars['body']);
// 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']));
} }
$vars['body'] = Format::sanitize($vars['body']);
$body = Format::sanitize((string) $vars['body']->convertTo('html'));
$poster = $vars['poster']; $poster = $vars['poster'];
if ($poster && is_object($poster)) if ($poster && is_object($poster))
...@@ -904,7 +891,7 @@ Class ThreadEntry { ...@@ -904,7 +891,7 @@ Class ThreadEntry {
if (!isset($vars['attachments']) || !$vars['attachments']) if (!isset($vars['attachments']) || !$vars['attachments'])
// Otherwise, body will be configured in a block below (after // Otherwise, body will be configured in a block below (after
// inline attachments are saved and updated in the database) // inline attachments are saved and updated in the database)
$sql.=' ,body='.db_input($vars['body']); $sql.=' ,body='.db_input($body);
if(isset($vars['pid'])) if(isset($vars['pid']))
$sql.=' ,pid='.db_input($vars['pid']); $sql.=' ,pid='.db_input($vars['pid']);
...@@ -941,12 +928,12 @@ Class ThreadEntry { ...@@ -941,12 +928,12 @@ Class ThreadEntry {
// content-id will be discarded, only the unique hash-code // content-id will be discarded, only the unique hash-code
// will be available to retrieve the image later // will be available to retrieve the image later
if ($a['cid'] && $a['key']) { if ($a['cid'] && $a['key']) {
$vars['body'] = str_replace('src="cid:'.$a['cid'].'"', $body = str_replace('src="cid:'.$a['cid'].'"',
'src="cid:'.$a['key'].'"', $vars['body']); 'src="cid:'.$a['key'].'"', $body);
} }
} }
unset($a); 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()); .' WHERE `id`='.db_input($entry->getId());
if (!db_query($sql) || !db_affected_rows()) if (!db_query($sql) || !db_affected_rows())
return false; return false;
...@@ -959,7 +946,7 @@ Class ThreadEntry { ...@@ -959,7 +946,7 @@ Class ThreadEntry {
$entry->saveEmailInfo($vars); $entry->saveEmailInfo($vars);
// Inline images (attached to the draft) // Inline images (attached to the draft)
$entry->saveAttachments(Draft::getAttachmentIds($vars['body'])); $entry->saveAttachments(Draft::getAttachmentIds($body));
return $entry; return $entry;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment