[#1001] Fix corrupted state of tokenizer (#1010)
authorAnthony BARRE <a@fasterize.com>
Mon, 5 Mar 2018 12:58:25 +0000 (13:58 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 5 Mar 2018 12:58:25 +0000 (13:58 +0100)
- case of roundBracketLevel inferior to 0.

lib/tokenizer/tokenize.js
test/fixtures/issue-1001-min.css [new file with mode: 0644]
test/fixtures/issue-1001.css [new file with mode: 0644]

index 8ad55d5..2d34e4d 100644 (file)
@@ -120,6 +120,7 @@ function intoTokens(source, externalContext, internalContext, isNested) {
     isCommentStart = !wasCommentEnd && level != Level.COMMENT && !isQuoted && character == Marker.ASTERISK && source[position.index - 1] == Marker.FORWARD_SLASH;
     isCommentEndMarker = !wasCommentStart && !isQuoted && character == Marker.FORWARD_SLASH && source[position.index - 1] == Marker.ASTERISK;
     isCommentEnd = level == Level.COMMENT && isCommentEndMarker;
+    roundBracketLevel = Math.max(roundBracketLevel, 0);
 
     metadata = buffer.length === 0 ?
       [position.line, position.column, position.source] :
diff --git a/test/fixtures/issue-1001-min.css b/test/fixtures/issue-1001-min.css
new file mode 100644 (file)
index 0000000..a412a4f
--- /dev/null
@@ -0,0 +1,2 @@
+.a{background-image:url(test/fixtures/bg-buttonh.png)}
+.e{background:url(/carte-bienvenue/bg2.jpg)}
diff --git a/test/fixtures/issue-1001.css b/test/fixtures/issue-1001.css
new file mode 100644 (file)
index 0000000..8865917
--- /dev/null
@@ -0,0 +1,4 @@
+.a{background-image:url('bg-buttonh.png'); }
+'/imagerie/booking/common/bg-buttonh.png');}
+.c{background:url(/carte-bienvenue/bg.jpg)}
+.e{background:url(/carte-bienvenue/bg2.jpg)}