Issue #2877131 by collinhaines, Liam Morland, sjerdo, hass, oadaeh, gnuget, johns996, gapple, aerozeppelin, mgifford, alexpott: CSS aggregation strips some essential whitespace within strings
parent
14023108d8
commit
2ceeb7101c
|
@ -3864,8 +3864,10 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
|
|||
// whitespace.
|
||||
// @see http://php.net/manual/regexp.reference.subpatterns.php
|
||||
$contents = preg_replace('<
|
||||
# Do not strip any space from within single or double quotes
|
||||
(' . $double_quot . '|' . $single_quot . ')
|
||||
# Strip leading and trailing whitespace.
|
||||
\s*([@{};,])\s*
|
||||
| \s*([@{};,])\s*
|
||||
# Strip only leading whitespace from:
|
||||
# - Closing parenthesis: Retain "@media (bar) and foo".
|
||||
| \s+([\)])
|
||||
|
@ -3873,11 +3875,11 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
|
|||
# - Opening parenthesis: Retain "@media (bar) and foo".
|
||||
# - Colon: Retain :pseudo-selectors.
|
||||
| ([\(:])\s+
|
||||
>xS',
|
||||
// Only one of the three capturing groups will match, so its reference
|
||||
>xSs',
|
||||
// Only one of the four capturing groups will match, so its reference
|
||||
// will contain the wanted value and the references for the
|
||||
// two non-matching groups will be replaced with empty strings.
|
||||
'$1$2$3',
|
||||
'$1$2$3$4',
|
||||
$contents
|
||||
);
|
||||
// End the file with a new line.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
.test1{display:block;}html .clear-block{height:1%;}.clear-block{display:block;font:italic bold 12px/30px Georgia,serif;}.test2{display:block;}.bkslshv1{background-color:#C00;}.test3{display:block;}.test4{display:block;}.comment-in-double-quotes:before{content:"/* ";}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-double-quotes:after{content:" */";}.comment-in-single-quotes:before{content:'/*';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-single-quotes:after{content:'*/';}.comment-in-mixed-quotes:before{content:'"/*"';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-mixed-quotes:after{content:"'*/'";}.comment-in-quotes-with-escaped:before{content:'/* \" \' */';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-quotes-with-escaped:after{content:"*/ \" \ '";}
|
||||
.test1{display:block;}img[style*="float: right"]{padding-left:5px;}html .clear-block{height:1%;}.clear-block{display:block;font:italic bold 12px/30px Georgia,serif;}.test2{display:block;}.bkslshv1{background-color:#C00;}.test3{display:block;}.test4{display:block;}.comment-in-double-quotes:before{content:"/* ";}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-double-quotes:after{content:" */";}.comment-in-single-quotes:before{content:'/*';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-single-quotes:after{content:'*/';}.comment-in-mixed-quotes:before{content:'"/*"';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-mixed-quotes:after{content:"'*/'";}.comment-in-quotes-with-escaped:before{content:'/* \" \' */';}.this_rule_must_stay{color:#F00;background-color:#FFF;}.comment-in-quotes-with-escaped:after{content:"*/ \" \ '";}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
|
||||
.is
|
||||
.a
|
||||
.test{font:1em/100% Verdana,sans-serif;color:#494949;}some :pseudo .thing{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;filter:progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction='180',strength='10');-ms-filter:"progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction='180',strength='10')";}::-moz-selection{background:#000;color:#fff;}::selection{background:#000;color:#fff;}@media print{*{background:#000 !important;color:#fff !important;}@page{margin:0.5cm;}}@media screen and (max-device-width:480px){background:#000;color:#fff;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
||||
.test{font:1em/100% Verdana,sans-serif;color:#494949;}some :pseudo .thing{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;filter:progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction='180',strength='10');-ms-filter:"progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10')";}::-moz-selection{background:#000;color:#fff;}::selection{background:#000;color:#fff;}@media print{*{background:#000 !important;color:#fff !important;}@page{margin:0.5cm;}}@media screen and (max-device-width:480px){background:#000;color:#fff;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* Example from https://www.w3.org/TR/CSS2/syndata.html#rule-sets */
|
||||
q[example="public class foo\
|
||||
{\
|
||||
private int x;\
|
||||
\
|
||||
foo(int x) {\
|
||||
this.x = x;\
|
||||
}\
|
||||
\
|
||||
}"] { color: red }
|
||||
|
||||
/* A pseudo selector with essential whitespace wrapped in quotes. */
|
||||
q[style*="quotes: none"] {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
q[style*='quotes: none'] {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: ": colon & escaped double \" quotes \".";
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: ' (brackets & escaped single \' quotes \') ';
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: "I'm Quote";
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
q[example="public class foo\
|
||||
{\
|
||||
private int x;\
|
||||
\
|
||||
foo(int x) {\
|
||||
this.x = x;\
|
||||
}\
|
||||
\
|
||||
}"]{color:red}q[style*="quotes: none"]{quotes:none;}q[style*='quotes: none']{quotes:none;}q:after{content:": colon & escaped double \" quotes \".";}q:after{content:' (brackets & escaped single \' quotes \') ';}q:after{content:"I'm Quote";}
|
|
@ -0,0 +1,31 @@
|
|||
/* Example from https://www.w3.org/TR/CSS2/syndata.html#rule-sets */
|
||||
q[example="public class foo\
|
||||
{\
|
||||
private int x;\
|
||||
\
|
||||
foo(int x) {\
|
||||
this.x = x;\
|
||||
}\
|
||||
\
|
||||
}"] { color: red }
|
||||
|
||||
/* A pseudo selector with essential whitespace wrapped in quotes. */
|
||||
q[style*="quotes: none"] {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
q[style*='quotes: none'] {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: ": colon & escaped double \" quotes \".";
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: ' (brackets & escaped single \' quotes \') ';
|
||||
}
|
||||
|
||||
q:after {
|
||||
content: "I'm Quote";
|
||||
}
|
|
@ -1069,7 +1069,8 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
|
|||
'css_input_without_import.css',
|
||||
'css_input_with_import.css',
|
||||
'css_subfolder/css_input_with_import.css',
|
||||
'comment_hacks.css'
|
||||
'comment_hacks.css',
|
||||
'quotes.css',
|
||||
);
|
||||
$path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
|
||||
foreach ($testfiles as $file) {
|
||||
|
|
Loading…
Reference in New Issue