Commit dc583b73 authored by alexpott's avatar alexpott

Issue #936316 by vaplas, johns996, aerozeppelin, mgifford, gapple, gnuget: CSS...

Issue #936316 by vaplas, johns996, aerozeppelin, mgifford, gapple, gnuget: CSS aggregation strips some essential whitespace within strings
parent ffd4d6a8
......@@ -205,8 +205,10 @@ protected function processCss($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+([\)])
......@@ -214,11 +216,11 @@ protected function processCss($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.
......
......@@ -187,6 +187,19 @@ function providerTestOptimize() {
),
'.utf16-byte-order-mark-test{content:"☃";}' . "\n",
),
array(
array(
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'quotes.css',
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'basename' => 'quotes.css',
),
file_get_contents($absolute_path . 'quotes.css.optimized.css'),
),
);
}
......
/* 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";
}
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";}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment