Fix bug where HTML messages with @media styles could moddify style of page body (#5811)

pull/5838/head
Aleksander Machniak 7 years ago
parent 18279e01b8
commit 1fcf7bfab3

@ -17,6 +17,7 @@ CHANGELOG Roundcube Webmail
- Password: Fix compatibility with PHP 7+ in cpanel_webmail driver (#5820)
- Fix decoding non-ascii attachment names from TNEF attachments (#5646, #5799)
- Fix uninitialized string offset in rcube_utils::bin2ascii() and make sure rcube_utils::random_bytes() result has always requested length (#5788)
- Fix bug where HTML messages with @media styles could moddify style of page body (#5811)
RELEASE 1.3.0
-------------

@ -430,7 +430,10 @@ class rcube_utils
$source = preg_replace(
array(
'/(^\s*<\!--)|(-->\s*$)/m',
'/(^\s*|,\s*|\}\s*)([a-z0-9\._#\*][a-z0-9\.\-_]*)/im',
// (?!##str) below is to not match with ##str_replacement_0##
// from rcube_string_replacer used above, this is needed for
// cases like @media { body { position: fixed; } } (#5811)
'/(^\s*|,\s*|\}\s*|\{\s*)((?!##str)[a-z0-9\._#\*][a-z0-9\.\-_]*)/im',
'/'.preg_quote($container_id, '/').'\s+body/i',
),
array(

@ -183,6 +183,7 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
$this->assertContains('#rcmbody table[class=w600]', $mod, 'Replace styles nested in @media block');
$this->assertContains('#rcmbody {width:600px', $mod, 'Replace body selector nested in @media block');
$this->assertContains('#rcmbody {min-width:474px', $mod, 'Replace body selector nested in @media block (#5811)');
}
/**

@ -15,6 +15,7 @@ div, p, a, li, td { -webkit-text-size-adjust:none; }
body {width:600px !important; margin:auto !important;}
.pict img {max-width:540px !important; height:auto !important;}
}
@media screen and (max-width:600px) { body {min-width:474px !important;} }
h1{ font-weight:bold; font-size:14px;color:#3c3c3c ;margin:0px; }
h2{ color:#8DB048 ; font-size:14px; font-weight:bold; margin-top:20px; border-bottom:1px solid #d6d6d6; padding-bottom:4px; }
h3{ color:#7e7e7e ; font-size:14px; font-weight:bold; margin:20px 0px 0px 0px; border-bottom:1px solid #d6d6d6; padding-bottom:0px 0px 4px 0px; }

Loading…
Cancel
Save