From d5f6d655da2b95da2851d50e421665af8bf5f2f1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sat, 01 Aug 2015 11:11:03 -0400 Subject: [PATCH] Workaround TinyMCE issue with <p> </p> sequence (#1490463) --- program/steps/mail/compose.inc | 20 ++++++++++++++++++-- program/steps/mail/sendmail.inc | 10 ++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 84ec3c3..505f5d6 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -1145,8 +1145,24 @@ if ($bodyIsHtml) { $body = rcmail_wash_html($body, array('safe' => 1), $cid_map); - // remove comments (produced by washtml) - $body = preg_replace('/<!--[^>]+-->/', '', $body); + // cleanup + $body = preg_replace(array( + // remove comments (produced by washtml) + '/<!--[^>]+-->/', + // remove <body> tags + '/<body([^>]*)>/i', + '/<\/body>/i', + // convert TinyMCE's empty-line sequence (#1490463) + '/<p>\xC2\xA0<\/p>/', + ), + array( + '', + '', + '', + '<p><br /></p>', + ), + $body + ); // replace cid with href in inline images links if (!empty($cid_map)) { diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index d83f26e..c791c3d 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -297,16 +297,22 @@ $message_body = preg_replace( array( + // remove empty signature div + '/<div id="_rc_sig">( )?<\/div>[\s\r\n]*$/', // remove signature's div ID '/\s*id="_rc_sig"/', // add inline css for blockquotes and container '/<blockquote>/', - '/<div class="pre">/' + '/<div class="pre">/', + // convert TinyMCE's new-line sequences (#1490463) + '/<p> <\/p>/', ), array( '', + '', '<blockquote type="cite" style="'.$b_style.'">', - '<div class="pre" style="'.$pre_style.'">' + '<div class="pre" style="'.$pre_style.'">', + '<p><br /></p>', ), $message_body); } -- Gitblit v1.9.1