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>&nbsp;</p> sequence (#1490463)

---
 program/steps/mail/sendmail.inc |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

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">(&nbsp;)?<\/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>&nbsp;<\/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