From 7c8ce07e8cb3af6700f2ca56714199677e3a4d4b 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 e466b37b8..3b05a94d3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ CHANGELOG Roundcube Webmail - Fix so bin/install-jsdeps.sh returns error code on error (#6704) - 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.4-rc1 --------------- diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php index 371c8f611..0459917a1 100644 --- a/program/lib/Roundcube/rcube_html2text.php +++ b/program/lib/Roundcube/rcube_html2text.php @@ -249,8 +249,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 ); @@ -673,9 +671,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 55ac60a60..202812c38 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' => 'ś', + ), ); }