Skip to content
Snippets Groups Projects
Commit b143ea6f authored by Jared Hancock's avatar Jared Hancock
Browse files

oops: Fix corruption of thread body posted by collabs

If the system receives an email by a collaborator which has not yet been
added to the ticket (a friend of a friend — that is, a collaborator forwards
an email to a third-party), a header is added to the thread body something
like:

Received From: afriendofafriend@mycompany.tld

However, if the thread body is text and the HTML ticket thread is enabled,
then the text formatting hint will be lost and the body will be assumed as
HTML deeper inside the thread entry creation process. Therefore, the
whitespace inside the resulting thread entry will be collapsed.

This patch addresses the issue by maintaining the original format hint with
the thread body.
parent 0be44456
No related branches found
No related tags found
No related merge requests found
......@@ -742,8 +742,14 @@ Class ThreadEntry {
else {
//XXX: Are we potentially leaking the email address to
// collaborators?
$vars['message'] = sprintf("Received From: %s\n\n%s",
$mailinfo['email'], $body);
$header = sprintf("Received From: %s\n\n", $mailinfo['email']);
if ($body instanceof HtmlThreadBody)
$header = nl2br($header);
// Add the banner to the top of the message
if ($body instanceof ThreadBody)
$body->prepend($header);
$vars['message'] = $body;
$vars['userId'] = 0; //Unknown user! //XXX: Assume ticket owner?
return $ticket->postMessage($vars, 'Email');
}
......@@ -1385,6 +1391,14 @@ class ThreadBody /* extends SplString */ {
return $this->display('html');
}
function prepend($what) {
$this->body = $what . $this->body;
}
function append($what) {
$this->body .= $what;
}
function asVar() {
// Email template, assume HTML
return $this->display('email');
......
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