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

Fix fixup routines for JSON/XML parsers to use the new ticket thread body

model.
parent 897ef322
No related branches found
No related tags found
No related merge requests found
......@@ -337,20 +337,12 @@ class ApiXmlDataParser extends XmlDataParser {
}
if (isset($value['encoding']))
$value['body'] = Format::utf8encode($value['body'], $value['encoding']);
// HTML-ize text if html is enabled
if ($cfg->isHtmlThreadEnabled()
&& (!isset($value['type'])
|| strcasecmp($value['type'], 'text/html')))
$value = sprintf('<pre>%s</pre>',
Format::htmlchars($value['body']));
// Text-ify html if html is disabled
elseif (!$cfg->isHtmlThreadEnabled()
&& !strcasecmp($value['type'], 'text/html'))
$value = Format::html2text(Format::safe_html(
$value['body']), 100, false);
// Noop if they content-type matches the html setting
if (!strcasecmp($value['type'], 'text/html'))
$value = new HtmlThreadBody($value['body']);
else
$value = $value['body'];
$value = new TextThreadBody($value['body']);
} else if ($key == "attachments") {
if(!isset($value['file'][':text']))
$value = $value['file'];
......@@ -390,11 +382,12 @@ class ApiJsonDataParser extends JsonDataParser {
} elseif ($key == "message") {
// Allow message specified in RFC 2397 format
$data = Format::parseRfc2397($value, 'utf-8');
if (!isset($data['type']) || $data['type'] != 'text/html')
$value = sprintf('<pre>%s</pre>',
Format::htmlchars($data['data']));
if (isset($data['type']) && $data['type'] == 'text/html')
$value = new HtmlThreadBody($data['data']);
else
$value = $data['data'];
$value = new TextThreadBody($data['data']);
} else if ($key == "attachments") {
foreach ($value as &$info) {
$data = reset($info);
......@@ -432,9 +425,6 @@ class ApiEmailDataParser extends EmailDataParser {
$data['source'] = 'Email';
if(!$data['message'])
$data['message'] = '--';
if(!$data['subject'])
$data['subject'] = '[No Subject]';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment