Skip to content

Commit 5a86caa

Browse files
authored
Merge pull request glayzzle#918 from MaartenStaa/fix-attribute-parsing-issues
Fix attribute parsing issues
2 parents 7383793 + b623066 commit 5a86caa

File tree

4 files changed

+866
-5
lines changed

4 files changed

+866
-5
lines changed

src/lexer/attribute.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"use strict";
77

88
module.exports = {
9+
attributeIndex: 0,
10+
attributeListDepth: {},
911
matchST_ATTRIBUTE: function () {
10-
let listDepth = 0;
1112
let ch = this.input();
1213
if (this.is_WHITESPACE()) {
1314
do {
@@ -18,20 +19,33 @@ module.exports = {
1819
}
1920
switch (ch) {
2021
case "]":
21-
if (listDepth === 0) {
22+
if (this.attributeListDepth[this.attributeIndex] === 0) {
23+
delete this.attributeListDepth[this.attributeIndex];
24+
this.attributeIndex--;
2225
this.popState();
2326
} else {
2427
/* istanbul ignore next */
25-
listDepth--;
28+
this.attributeListDepth[this.attributeIndex]--;
2629
}
2730
return "]";
2831
case "(":
2932
case ")":
3033
case ":":
3134
case "=":
35+
case "|":
36+
case "&":
37+
case "^":
38+
case "-":
39+
case "+":
40+
case "*":
41+
case "%":
42+
case "~":
43+
case "<":
44+
case ">":
45+
case "!":
3246
return this.consume_TOKEN();
3347
case "[":
34-
listDepth++;
48+
this.attributeListDepth[this.attributeIndex]++;
3549
return "[";
3650
case ",":
3751
return ",";
@@ -45,6 +59,8 @@ module.exports = {
4559
} else if (this._input[this.offset] === "*") {
4660
this.input();
4761
return this.T_DOC_COMMENT();
62+
} else {
63+
return this.consume_TOKEN();
4864
}
4965
}
5066
if (this.is_LABEL_START() || ch === "\\") {
@@ -55,7 +71,7 @@ module.exports = {
5571
break;
5672
}
5773
}
58-
return this.tok.T_STRING;
74+
return this.T_STRING();
5975
} else if (this.is_NUM()) {
6076
return this.consume_NUM();
6177
}

src/lexer/scripting.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
case "#":
1919
if (this.version >= 800 && this._input[this.offset] === "[") {
2020
this.input();
21+
this.attributeListDepth[++this.attributeIndex] = 0;
2122
this.begin("ST_ATTRIBUTE");
2223
return this.tok.T_ATTRIBUTE;
2324
}

0 commit comments

Comments
 (0)