Outlook conditional comments <![if !vml]> / <![endif]> shown as text in thread body #5676 from il2020/vml-fix

Outlook conditional comments <![if !vml]> / <![endif]> shown as text in thread body
This commit is contained in:
FreeScout
2026-09-28 14:15:16 +03:00
committed by GitHub
2 changed files with 10 additions and 1 deletions

View File

@@ -1598,8 +1598,12 @@ class FetchEmails extends Command
$body = \Eventy::filter('fetch_emails.separate_reply.preprocess_body', $body ?? '');
if ($is_html) {
// Remove Outlook "downlevel-revealed" conditional comments (<![if !vml]>...<![endif]>),
// preserving the data inside. Otherwise DOMDocument turns them into escaped text.
$body = preg_replace('/<!\[(?:if\s[^\]]*|endif)\]>/i', '', $body) ?: $body;
// Extract body content from HTML
// Proton has it's own unique way of placing replies:
// https://github.com/freescout-help-desk/freescout/issues/4537#issuecomment-2629836738
if ($is_reply

View File

@@ -329,6 +329,11 @@ class Thread extends Model
// https://github.com/freescout-helpdesk/freescout/pull/3865#issuecomment-1990758149
$body = preg_replace('/<!\-\-\[if [^>]+\]><!\-\->(.*?)<![ ]+\-\-<!\[endif\]\-\->/s', '$1', $body);
// Remove Outlook "downlevel-revealed" conditional comments (<![if !vml]>...<![endif]>),
// preserving the data inside. Browsers ignore them, but the purifier escapes them as text.
// Emails fetched before the fix have them already escaped (&lt;![if !vml]&gt;) in the DB.
$body = preg_replace('/(?:<|&lt;)!\[(?:if\s[^\]]*|endif)\](?:>|&gt;)/i', '', $body) ?: $body;
// https://github.com/freescout-helpdesk/freescout/issues/3894
// Remove <!--[if !mso]><!--> and <!--<![endif]--> comments, preserving the data inside
//$body = preg_replace('/(<!\-\-\[if [^>]+\]>|<!\[endif\]\-\->)/', '', $body);