From 58721e3037671888f82d75fd8e91a8622405af45 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 16 Aug 2024 19:56:51 +0200 Subject: [PATCH] Fix regression where HTML messages were displayed unstyled (#9586) --- CHANGELOG.md | 1 + program/lib/Roundcube/rcube_washtml.php | 6 ++++++ tests/Actions/Mail/IndexTest.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13be3b32b94..9422299e61f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ - Fix deprecated (in PHP 8.4) use of session_set_save_handler() (#9060) - Fix potential HTTP protocol version mismatch (#8982) - Fix regression where printing/scaling/rotating image attachments was broken (#9571) +- Fix regression where HTML messages were displayed unstyled (#9586) ## Release 1.6.8 diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php index bc71378857f..95a63711397 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -689,6 +689,12 @@ public function wash($html) */ public function get_config($prop) { + $config_props = ['html_elements', 'html_attribs', 'ignore_elements', 'void_elements', 'css_prefix']; + + if (in_array($prop, $config_props)) { + return $this->{"_{$prop}"}; + } + return $this->config[$prop] ?? null; } diff --git a/tests/Actions/Mail/IndexTest.php b/tests/Actions/Mail/IndexTest.php index cedd474d1f6..2e41e3ac322 100644 --- a/tests/Actions/Mail/IndexTest.php +++ b/tests/Actions/Mail/IndexTest.php @@ -427,6 +427,21 @@ public function test_html_body_attributes() $this->assertSame(' ' . $part->body . '', $washed); } + /** + * Test handling css style in HTML in wash_html() method + */ + public function test_wash_html() + { + $html = '
Test
' + . ''; + $opts = ['safe' => false, 'css_prefix' => 'v1', 'add_comments' => false]; + + $washed = \rcmail_action_mail_index::wash_html($html, $opts); + + $this->assertStringContainsString('
', $washed); + $this->assertStringContainsString('', $washed); + } + /** * Test handling of body style attributes */