Skip to content

Commit

Permalink
Fix regression where HTML messages were displayed unstyled (#9586)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Aug 16, 2024
1 parent 8685ca9 commit 58721e3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions program/lib/Roundcube/rcube_washtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Actions/Mail/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ public function test_html_body_attributes()
$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
*/
Expand Down

0 comments on commit 58721e3

Please sign in to comment.