From ca7fc75bec34ab7c839f3a3f3ec14872110f4a86 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 10 Aug 2015 10:17:05 +0200 Subject: [PATCH] Fix "washing" of style elements wrapped into many lines --- CHANGELOG | 1 + program/lib/Roundcube/rcube_washtml.php | 3 +++ tests/Framework/Washtml.php | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 305eaa692..d3753d88f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ CHANGELOG Roundcube Webmail - Fix error when using back button after sending an email (#1490009) - Fix removing signature when switching to identity with an empty sig in HTML mode (#1490470) - Disable links list generation on html-to-text conversion of identities or composed message (#1490437) +- Fix "washing" of style elements wrapped into many lines RELEASE 1.1.2 ------------- diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php index b042f5f80..c3f73fa1d 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -174,6 +174,9 @@ class rcube_washtml { $result = array(); + // Remove unwanted white-space characters so regular expressions below work better + $style = preg_replace('/[\n\r\s\t]+/', ' ', $style); + foreach (explode(';', $style) as $declaration) { if (preg_match('/^\s*([a-z\-]+)\s*:\s*(.*)\s*$/i', $declaration, $match)) { $cssid = $match[1]; diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php index e4e3de41f..acc611ede 100644 --- a/tests/Framework/Washtml.php +++ b/tests/Framework/Washtml.php @@ -182,6 +182,14 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase $this->assertRegExp('|line-height: 1;|', $washed, "Untouched line-height (#1489917)"); $this->assertRegExp('|; height: 10px|', $washed, "Fixed height units"); + + $html = "
"; + $expected = "
"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertTrue(strpos($washed, $expected) !== false, "White-space and new-line characters handling"); } /**