File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,15 @@ public function getCleanBody($body = '')
316316 // Cut out "collapse" class as it hides elements.
317317 $ body = preg_replace ("/(<[^<> \r\n]+class=([ \"'][^ \"']* |[ \"']))(collapse|hidden)([ \"' ])/ " , '$1$4 ' , $ body ) ?: $ body ;
318318
319+ // Take care of MSO-comments.
320+ // https://github.com/freescout-help-desk/freescout/issues/5068
321+ // Step 1: Completely remove the MSO-specific blocks.
322+ // The 's' flag allows '.' to match newlines, and 'i' makes it case-insensitive.
323+ $ body = preg_replace ('/<!--\[if mso\]>.*?<!\[endif\]-->/is ' , '' , $ body );
324+ // Step 2: Unwrap the standard HTML from the "not mso" comments.
325+ // This reveals the standard <a> tag for the purifier.
326+ $ body = preg_replace ('/<!--\[if !mso\]><!--\s*-->(.*?)<!--\s*<!\[endif\]-->/is ' , '$1 ' , $ body );
327+
319328 // Remove only the <!--[if !mso]><!--> and <!--<![endif]--> around the elements.
320329 // https://github.com/freescout-helpdesk/freescout/pull/3865#issuecomment-1990758149
321330 $ body = preg_replace ('/<!\-\-\[if [^>]+\]><!\-\->(.*?)<![ ]+\-\-<!\[endif\]\-\->/s ' , '$1 ' , $ body );
You can’t perform that action at this time.
0 commit comments