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 | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 8fffbd4..505f5d6 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -47,9 +47,11 @@ if (!is_array($COMPOSE)) { // Infinite redirect prevention in case of broken session (#1487028) if ($COMPOSE_ID) { - rcube::raise_error(array('code' => 500, 'type' => 'php', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Invalid compose ID"), true, true); + // if we know the message with specified ID was already sent + // we can ignore the error and compose a new message (#1490009) + if ($COMPOSE_ID != $_SESSION['last_compose_session']) { + rcube::raise_error(array('code' => 450), false, true); + } } $COMPOSE_ID = uniqid(mt_rand()); @@ -1143,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)) { -- Gitblit v1.9.1