Skip to content

Commit 4a03410

Browse files
committed
test
1 parent 14e80e4 commit 4a03410

File tree

3 files changed

+373
-88
lines changed

3 files changed

+373
-88
lines changed

javascript/extractor/src/com/semmle/js/parser/RegExpParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,18 @@ private <T extends RegExpTerm> T finishTerm(T term) {
226226
private RegExpTerm parseDisjunction() {
227227
SourceLocation loc = new SourceLocation(pos());
228228
List<RegExpTerm> disjuncts = new ArrayList<>();
229-
disjuncts.add(this.parseIntersection());
229+
disjuncts.add(this.parseAlternative());
230230
while (this.match("|")) {
231-
disjuncts.add(this.parseIntersection());
231+
disjuncts.add(this.parseAlternative());
232232
}
233233
if (disjuncts.size() == 1) return disjuncts.get(0);
234234
return this.finishTerm(new Disjunction(loc, disjuncts));
235-
}
235+
}
236236

237237
private RegExpTerm parseAlternative() {
238238
SourceLocation loc = new SourceLocation(pos());
239239
List<RegExpTerm> elements = new ArrayList<>();
240-
while (!this.lookahead(null, "|", "&&", ")")) elements.add(this.parseTerm());
240+
while (!this.lookahead(null, "|", ")")) elements.add(this.parseTerm());
241241
if (elements.size() == 1) return elements.get(0);
242242
return this.finishTerm(new Sequence(loc, elements));
243243
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
/[[abc]&&[bcd]]/v
1+
/[[abc]&&[bcd]]/v; // Valid use of intersection operator, matches b or c
2+
/abc&&bcd/v; //Valid regex, but no intersection operation: Matches the literal string "abc&&bcd"
3+
/[abc]&&[bcd]/v; // Valid regex, but incorrect intersection operation:
4+
// - Matches a single character from [abc]
5+
// - Then the literal "&&"
6+
// - Then a single character from [bcd]
7+
/[abc&&bcd]/v; // Compilation error due to invalid use of intersection operation

0 commit comments

Comments
 (0)