From d5f6d655da2b95da2851d50e421665af8bf5f2f1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 1 Aug 2015 17:11:03 +0200 Subject: [PATCH] Workaround TinyMCE issue with

 

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 84ec3c32a..505f5d644 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -1145,8 +1145,24 @@ function rcmail_create_draft_body($body, $bodyIsHtml) 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 tags + '/]*)>/i', + '/<\/body>/i', + // convert TinyMCE's empty-line sequence (#1490463) + '/

\xC2\xA0<\/p>/', + ), + array( + '', + '', + '', + '


', + ), + $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 d83f26e6a..c791c3d41 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -297,16 +297,22 @@ if (!$savedraft) { $message_body = preg_replace( array( + // remove empty signature div + '/
( )?<\/div>[\s\r\n]*$/', // remove signature's div ID '/\s*id="_rc_sig"/', // add inline css for blockquotes and container '/
/', - '/
/' + '/
/', + // convert TinyMCE's new-line sequences (#1490463) + '/

 <\/p>/', ), array( + '', '', '

', - '
' + '
', + '


', ), $message_body); }