summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-05-14 19:24:01 +0200
committerAndreas Gohr <andi@splitbrain.org>2014-05-14 19:24:01 +0200
commit918a4468877109c2ba2f82fa4e1a225a4738ed9a (patch)
treefac9b3bb89faf60895913960499faa727eab3e20 /lib/exe/css.php
parentcfb2335aca014812dc45fc4dc5a4289456e66e4c (diff)
downloadrpg-918a4468877109c2ba2f82fa4e1a225a4738ed9a.tar.gz
rpg-918a4468877109c2ba2f82fa4e1a225a4738ed9a.tar.bz2
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
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php31
1 files changed, 24 insertions, 7 deletions
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 :