From f343ecea09f8968d0655ff97fb7cea7a6d873a79 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/Index.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b7c2b6172..35346afb85c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - 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 e682b29142d..93ae9f7afc4 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -709,6 +709,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/Index.php b/tests/Actions/Mail/Index.php index b3ae049ea0c..d3fcca2bb69 100644 --- a/tests/Actions/Mail/Index.php +++ b/tests/Actions/Mail/Index.php @@ -422,6 +422,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 */