From 55ebae3c1e9665d8c7f6086769cba035a1afd0a0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 19 May 2019 08:12:50 +0200 Subject: [PATCH] Fix bug where bold/strong text was converted to upper-case on html-to-text conversion (6758) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_html2text.php | 5 ---- tests/Framework/Html2text.php | 33 ++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b871c9f46..f30908fdf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ CHANGELOG Roundcube Webmail - Enigma: Fix "decryption oracle" bug [CVE-2019-10740] (#6638) - Fix bug where bmp images couldn't be displayed on some systems (#6728) - Fix bug in parsing vCard data using PHP 7.3 due to an invalid regexp (#6744) +- Fix bug where bold/strong text was converted to upper-case on html-to-text conversion (6758) RELEASE 1.3.9 ------------- diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php index bd57ca23a..8d13c07eb 100644 --- a/program/lib/Roundcube/rcube_html2text.php +++ b/program/lib/Roundcube/rcube_html2text.php @@ -248,8 +248,6 @@ class rcube_html2text protected $callback_search = array( '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i', // '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 - '/<(b)( [^>]*)?>(.*?)<\/b>/i', // - '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and ); @@ -659,9 +657,6 @@ class rcube_html2text public function tags_preg_callback($matches) { switch (strtolower($matches[1])) { - case 'b': - case 'strong': - return $this->_toupper($matches[3]); case 'th': return $this->_toupper("\t\t". $matches[3] ."\n"); case 'h': diff --git a/tests/Framework/Html2text.php b/tests/Framework/Html2text.php index 889ba8241..7c2e794f7 100644 --- a/tests/Framework/Html2text.php +++ b/tests/Framework/Html2text.php @@ -27,19 +27,19 @@ class rc_html2text extends PHPUnit_Framework_TestCase 'out' => '"', ), 3 => array( - 'title' => 'HTML entity in STRONG tag', - 'in' => 'ś', // ś - 'out' => 'Ś', // upper ś + 'title' => 'HTML entity in H1 tag', + 'in' => '

ś

', // ś + 'out' => "Ś\n\n", // upper ś ), 4 => array( - 'title' => 'STRONG tag to upper-case conversion', - 'in' => 'ś', - 'out' => 'Ś', + 'title' => 'H1 tag to upper-case conversion', + 'in' => '

ś

', + 'out' => "Ś\n\n", ), 5 => array( - 'title' => 'STRONG inside B tag', - 'in' => 'ś', - 'out' => 'Ś', + 'title' => 'H1 inside B tag', + 'in' => '

ś

', + 'out' => "Ś\n\n", ), 6 => array( 'title' => 'Don\'t remove non-printable chars', @@ -56,6 +56,21 @@ class rc_html2text extends PHPUnit_Framework_TestCase 'in' => '
eye:   test
tes:   test
', 'out' => "eye: test\ntes: test", ), + 9 => array( + 'title' => 'HTML entity in STRONG tag', + 'in' => 'ś', // ś + 'out' => 'ś', + ), + 10 => array( + 'title' => 'STRONG tag to upper-case conversion', + 'in' => 'ś', + 'out' => 'ś', + ), + 11 => array( + 'title' => 'STRONG inside B tag', + 'in' => 'ś', + 'out' => 'ś', + ), ); }