diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2014-03-18 18:11:34 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2014-03-18 18:11:34 +0000 |
commit | 84abf1113fd407d4ffefe3313b8f0c3214f04b05 (patch) | |
tree | 7949d0578b77d9edfbe75049d0d75275c928eb8f /lib/exe | |
parent | 5bd7baebf302fad3f3448efc52c569bfaf8c9b22 (diff) | |
parent | 98cb8604b50ef15e66c424df8b433f115f05e548 (diff) | |
download | rpg-84abf1113fd407d4ffefe3313b8f0c3214f04b05.tar.gz rpg-84abf1113fd407d4ffefe3313b8f0c3214f04b05.tar.bz2 |
Merge pull request #586 from splitbrain/jqueryupdate
JQuery Update
Diffstat (limited to 'lib/exe')
-rw-r--r-- | lib/exe/css.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index ab5c03f0e..41d9a65b1 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('/(?<!:)\/\/.*$/m','',$css); + $css = preg_replace_callback('/^.*\/\/.*$/m','css_onelinecomment_cb',$css); // strip whitespaces $css = preg_replace('![\r\n\t ]+!',' ',$css); @@ -588,4 +588,41 @@ function css_comment_cb($matches){ return $matches[0]; } +/** + * Callback for css_compress() + * + * Strips one line comments but makes sure it will not destroy url() constructs with slashes + * + * @param $matches + * @return string + */ +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); + break; + } + if($nexturl === false || $nextcom < $nexturl) { + // no url anymore, strip comment and be done + $out .= substr($line, $i, $nextcom-$i); + break; + } + // we have an upcoming url + $urlclose = strpos($line, ')', $nexturl); + $out .= substr($line, $i, $urlclose-$i); + $i = $urlclose; + } + + return $out; +} + //Setup VIM: ex: et ts=4 : |