SuiteCRM 8.2.4 case subject variable empty

Hi,

I have recently upgrade to SuiteCRM version 8.2.4 installed on Ubuntu (18.04) with MYSQL 5.7 and php 8.0.

I have managed to create case from emails but the email subject line always remains empty , it appears as ‘no subject)’ .

I would really appreciate it if someone can help me understand why this could be happening and a fix for the issue?

Hi, do you still remember how you fixed it?

I think this is a bug with the latest version. It just started happening to me as well.

Did it happen in v8.8.1? Do you guys did any custom changes in the Cases module?

The issue I don’t think is in the cases module it’s in the inbound email module. There was some work done to purify the html of the subject line and basically if it doesn’t like it, it returns (no subject). I’m troublehsooting it now.

1 Like

In inboundemail.php I can see the subject in many places was changed from:

$email->name = $this->handleMimeHeaderDecode($parsedFullHeader->subject);
TO:
$email->name = purify_html($this->handleMimeHeaderDecode($parsedFullHeader->subject)); $email->name = purify_html($this->handleMimeHeaderDecode($parsedFullHeader->subject));

Still havn’t figure out what specifically is the problem, but reverting the file back to 7.14.5 version of inboundemail.php totally fixes the problem.

Is this a workaround for your issue?

No here is the problem:

I just created the bug and the fix.

The fix is tto replace line 5494 in InboundEmail.php:

$email->name = purify_html($this->handleMimeHeaderDecode($parsedFullHeader->subject));

With:

$__rawSubject = '';
if (isset($parsedFullHeader->subject) && (string)$parsedFullHeader->subject !== '') {
    $__rawSubject = (string)$parsedFullHeader->subject;
} elseif (isset($header->subject) && (string)$header->subject !== '') {
    $__rawSubject = (string)$header->subject;
}

$__decoded = (string) $this->handleMimeHeaderDecode($__rawSubject);
$__purified = purify_html($__decoded);
// If purify_html() strips everything, fall back to the decoded text
$email->name = ($__purified !== '') ? $__purified : $__decoded;

Basically if the purifier returns null, then fall back to the un purified raw subject line. Otherwise, use the purified one.

1 Like

@pstevens Thank you!

The fix works for my SuiteCRM 8.8.1 too. The line replaced is at 5498

I notice that there is another similar line at 5727. I assume that we do not need to replace it.

Great, glad it works for you. I haven’t tested changing up the other line thats like this one. Likely it should be changed too, but I haven’t seen any other blank subject issues but if they arise the second occurrence is likely something to consider as well.