From 53cbebf8ade5d9994479370cc78ac4e10c23c887 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 09 Apr 2015 04:11:00 -0400
Subject: [PATCH] Fix handling spaces after <br> on html2text conversion

---
 tests/Framework/Html2text.php             |    5 +++++
 program/lib/Roundcube/rcube_html2text.php |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php
index 284e50d..00a59a7 100644
--- a/program/lib/Roundcube/rcube_html2text.php
+++ b/program/lib/Roundcube/rcube_html2text.php
@@ -142,7 +142,7 @@
         '/<script[^>]*>.*?<\/script>/i',         // <script>s -- which strip_tags supposedly has problems with
         '/<style[^>]*>.*?<\/style>/i',           // <style>s -- which strip_tags supposedly has problems with
         '/<p[^>]*>/i',                           // <P>
-        '/<br[^>]*>/i',                          // <br>
+        '/<br[^>]*>\s*/i',                       // <br>
         '/<i[^>]*>(.*?)<\/i>/i',                 // <i>
         '/<em[^>]*>(.*?)<\/em>/i',               // <em>
         '/(<ul[^>]*>|<\/ul>)/i',                 // <ul> and </ul>
diff --git a/tests/Framework/Html2text.php b/tests/Framework/Html2text.php
index 76b1f16..dee7670 100644
--- a/tests/Framework/Html2text.php
+++ b/tests/Framework/Html2text.php
@@ -46,6 +46,11 @@
                 'in'    => chr(0x002).chr(0x003),
                 'out'   => chr(0x002).chr(0x003),
             ),
+            7 => array(
+                'title' => 'Remove spaces after <br>',
+                'in'    => 'test<br>  test',
+                'out'   => "test\ntest",
+            ),
         );
     }
 

--
Gitblit v1.9.1