File: Fix-regression-where-HTML-messages-were-displayed-unstyle.patch

package info (click to toggle)
roundcube 1.6.5%2Bdfsg-1%2Bdeb12u5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 45,000 kB
  • sloc: javascript: 204,325; php: 75,933; sql: 3,150; sh: 2,878; pascal: 1,079; makefile: 229; xml: 93; perl: 73; ansic: 48; python: 21
file content (54 lines) | stat: -rw-r--r-- 2,180 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 16 Aug 2024 19:56:51 +0200
Subject: Fix regression where HTML messages were displayed unstyled

Origin: https://github.com/roundcube/roundcubemail/commit/f343ecea09f8968d0655ff97fb7cea7a6d873a79
Bug: https://github.com/roundcube/roundcubemail/issues/9586
---
 program/lib/Roundcube/rcube_washtml.php |  6 ++++++
 tests/Actions/Mail/Index.php            | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index e9dcea4..281d369 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -709,6 +709,12 @@ class rcube_washtml
      */
     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 b3ae049..d3fcca2 100644
--- a/tests/Actions/Mail/Index.php
+++ b/tests/Actions/Mail/Index.php
@@ -422,6 +422,21 @@ class Actions_Mail_Index extends ActionTestCase
         $this->assertSame('<html><head></head>' . $part->body . '</html>', $washed);
     }
 
+    /**
+     * Test handling css style in HTML in wash_html() method
+     */
+    public function test_wash_html()
+    {
+        $html = '<div id="testid" class="testclass">Test</div>'
+            . '<style type="text/css">#testid .testclass { color: red; } *.testclass { font-weight: bold; }</style>';
+        $opts = ['safe' => false, 'css_prefix' => 'v1', 'add_comments' => false];
+
+        $washed = \rcmail_action_mail_index::wash_html($html, $opts);
+
+        $this->assertStringContainsString('<div id="v1testid" class="v1testclass">', $washed);
+        $this->assertStringContainsString('<style type="text/css">#v1testid .v1testclass { color: red; } *.v1testclass { font-weight: bold; }</style>', $washed);
+    }
+
     /**
      * Test handling of body style attributes
      */