Jump to:
| Project: | Chaos tool suite (ctools) |
| Version: | 6.x-1.10 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
Hi,
Inputing the following css to ctools_css_disassemble which cuts out valid css.
For example second css element (and mostly all others) "border-top-color: #301d30;" being cut out because it, does not have a "{" character in it in this line:
if (empty($statement) || !strpos($statement, '{')) {
continue;
}I'm not sure how it is intended to work but maybe the
// Split out each statement is not splitting the array correctly
$statements = preg_split('/[;}]/', $css);Running split out each statement:
input array:
#main { background-color: #e01be0; border-top-color: #301d30; .........
output array:
Array ( [0] => #main { background-color: #e01be0 [1] => border-top-color: #301d30......
But since 500k sites are using this module leads me to the conclusion that I'm wrong but than why is the produced array is wrong?
Please see the below input and output array after running the array through ctools_css_disassemble
Input array:
#main { background-color: #e01be0; border-top-color: #301d30; border-right-color: #301d30; border-bottom-color: #301d30; border-left-color: #301d30; background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_716.png); } #main:after { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_736.png); opacity: 0.5; } .header_background { opacity: 0.5; } #main .header_background:after { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_726.png); opacity: 0.3; background-color: #1a1a1a; } #main .header_background { opacity: 0.75; background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_730.png); background-color: #571357; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-bottom-width: 8px; border-top-color: #c41cc4; border-right-color: #c41cc4; border-bottom-color: #c41cc4; border-left-color: #c41cc4; background-position: 50% 0%; } #main .header_background #logo { border-top-style: double; border-right-style: double; border-bottom-style: double; border-left-style: double; border-top-color: #091a14; border-right-color: #091a14; border-bottom-color: #091a14; border-left-color: #091a14; } #main .header_background a #logo { background-image: none; background-color: #000000; } #main .header_background a #logo:after { background-color: transparent; } #main #logo a #logo { background-color: transparent; opacity: 0.9; } { background-image: none; background-repeat: repeat; font-family: Tahoma,Geneva,Sans-Serif; } #main .int { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_743.png); } #main .int:after { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_724.png); } #main .int .sidebar #block7 { background-color: #94ad03; background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_743.png); background-position: 0% 0%; background-repeat: repeat; } #main .int .sidebar { background-color: transparent; } #main .int #left-col .ind .sidebar #block2 .block-top .block-bot .inner { background-image: none; background-color: transparent; } #main .int #left-col .ind .sidebar #block2 { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_725.png); background-color: #ffffff; opacity: 0.5; } #main .int #contcol #nodemiddle { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_719.png); background-color: #ededed; background-position: 50% 50%; } #main .int #contcol { background-color: #d19bd1; } #main .int #left-col .ind .sidebar #block3 .block-top .block-bot .inner { background-image: url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_741.png); background-position: 50% 50%; } Output array:
Array ( [#main] => Array ( [background-color] => #e01be0 ) [#main:after] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_736.png) ) [.header_background] => Array ( [opacity] => 0.5 ) [#main .header_background:after] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_726.png) ) [#main .header_background] => Array ( [opacity] => 0.75 ) [#main .header_background #logo] => Array ( [border-top-style] => double ) [#main .header_background a #logo] => Array ( [background-image] => none ) [#main .header_background a #logo:after] => Array ( [background-color] => transparent ) [#main #logo a #logo] => Array ( [background-color] => transparent ) [#main .int] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_743.png) ) [#main .int:after] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_724.png) ) [#main .int .sidebar #block7] => Array ( [background-color] => #94ad03 ) [#main .int .sidebar] => Array ( [background-color] => transparent ) [#main .int #left-col .ind .sidebar #block2 .block-top .block-bot .inner] => Array ( [background-image] => none ) [#main .int #left-col .ind .sidebar #block2] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_725.png) ) [#main .int #contcol #nodemiddle] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_719.png) ) [#main .int #contcol] => Array ( [background-color] => #d19bd1 ) [#main .int #left-col .ind .sidebar #block3 .block-top .block-bot .inner] => Array ( [background-image] => url(http://p71.weboldal.biz/sites/default/files/sweaver/sweaver_image_741.png) ) )
Comments
#1
ctools/includes/css.inc:
Line 312:
$statements = preg_split('/[;}]/', $css);
needs to be changed to:
$statements = preg_split('/[}]/', $css);
Please review this modification and apply it to your version if approved. The above error ";" filtered valid css elements out and and produced incorrect css in sweaver for anonymous users in live.css file and therefore created different look for admin and anonymous user after publishing changes.
Thanks
#2
The line you refer to was introduced as a security fix. It's possible it did break things.
It has since changed again though, please give the dev version and see if it solves your issue.