From fe5a50c39e9bd837f887ea7ad8335717a6c6ab92 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Mar 2014 19:37:43 +0100 Subject: fix single line comments in CSS compression double slashes in url() always have to be ignored --- lib/exe/css.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..0a2a5a406 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -552,7 +552,7 @@ function css_compress($css){ $css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css); //strip (incorrect but common) one line comments - $css = preg_replace('/(? Date: Wed, 5 Mar 2014 20:06:24 +0100 Subject: fixed online comment stripping --- lib/exe/css.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 0a2a5a406..178895e99 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -611,16 +611,11 @@ function css_onelinecomment_cb($matches) { $out .= substr($line, $i, $len-$i); break; } - if($nexturl === false) { + if($nexturl === false || $nextcom < $nexturl) { // no url anymore, strip comment and be done $out .= substr($line, $i, $nextcom-$i); break; } - if($nextcom < $nexturl) { - // that comment comments out the url - $out .= substr($line, $i, $len-$i); - break; - } // we have an upcoming url $urlclose = strpos($line, ')', $nexturl); $out .= substr($line, $i, $urlclose-$i); -- cgit v1.2.3 From f8fb2d1811251304687b805a60b489f63cb5c4fb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Mar 2014 21:29:33 +0100 Subject: strip sourcemaps in CSS and JS #601 source maps are invalid for our dispatched sources and may even cause problems. this makes sure any sourcemap declarations are stripped from the output --- lib/exe/css.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..9ac70905b 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -133,6 +133,9 @@ function css_out(){ $css = ob_get_contents(); ob_end_clean(); + // strip any source maps + stripsourcemaps($css); + // apply style replacements $css = css_applystyle($css, $styleini['replacements']); -- cgit v1.2.3 From 259571aa7559630d429d0046aa56d1089a6eed17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Sun, 16 Mar 2014 10:20:45 +0100 Subject: Fixed cache dependency for template's style.ini Web path was used instead of filesystem one. --- lib/exe/css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..ab5c03f0e 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -56,7 +56,7 @@ function css_out(){ } // cache influencers - $tplinc = tpl_basedir($tpl); + $tplinc = tpl_incdir($tpl); $cache_files = getConfigFiles('main'); $cache_files[] = $tplinc.'style.ini'; $cache_files[] = $tplinc.'style.local.ini'; // @deprecated -- cgit v1.2.3 From 918a4468877109c2ba2f82fa4e1a225a4738ed9a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 14 May 2014 19:24:01 +0200 Subject: don't treat double slashes as comments when used in string This avoids treating double slashes as single line comments in CSS when they are used in a filter or content string. closes #638 --- lib/exe/css.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 30d0d18c5..6c1d60751 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -602,30 +602,47 @@ function css_comment_cb($matches){ function css_onelinecomment_cb($matches) { $line = $matches[0]; - $out = ''; $i = 0; $len = strlen($line); + while ($i< $len){ $nextcom = strpos($line, '//', $i); $nexturl = stripos($line, 'url(', $i); if($nextcom === false) { // no more comments, we're done - $out .= substr($line, $i, $len-$i); + $i = $len; break; } + + // keep any quoted string that starts before a comment + $nextsqt = strpos($line, "'", $i); + $nextdqt = strpos($line, '"', $i); + if(min($nextsqt, $nextdqt) < $nextcom) { + $skipto = false; + if($nextsqt !== false && ($nextdqt === false || $nextsqt < $nextdqt)) { + $skipto = strpos($line, "'", $nextsqt+1) +1; + } else if ($nextdqt !== false) { + $skipto = strpos($line, '"', $nextdqt+1) +1; + } + + if($skipto !== false) { + $i = $skipto; + continue; + } + } + if($nexturl === false || $nextcom < $nexturl) { // no url anymore, strip comment and be done - $out .= substr($line, $i, $nextcom-$i); + $i = $nextcom; break; } + // we have an upcoming url - $urlclose = strpos($line, ')', $nexturl); - $out .= substr($line, $i, $urlclose-$i); - $i = $urlclose; + $i = strpos($line, ')', $nexturl); } - return $out; + return substr($line, 0, $i); } //Setup VIM: ex: et ts=4 : -- cgit v1.2.3