Skip to content

Commit b4e6fb7

Browse files
committed
JS: Consider empty regexp to be obviously empty
1 parent e07e6c9 commit b4e6fb7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

javascript/ql/src/RegExp/RegExpAlwaysMatches.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ predicate isUniversalRegExp(RegExpTerm term) {
5454
or
5555
child.(RegExpCharacterClass).isUniversalClass()
5656
)
57+
or
58+
term.(RegExpSequence).getNumChild() = 0
5759
}
5860

5961
/**

javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches/tst.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ function nonWordBoundary(x) {
8383
}
8484

8585
function emptyRegex(x) {
86-
return new RegExp("").test(x); // NOT OK
86+
return new RegExp("").test(x); // OK
8787
}
8888

8989
function parserTest(x) {
9090
/(\w\s*:\s*[^:}]+|#){|@import[^\n]+(?:url|,)/.test(x); // OK
91-
/^((?:a{0,2}|-)|\w\{\d,\d\})+X$/.text(x); // ok
92-
}
91+
/^((?:a{0,2}|-)|\w\{\d,\d\})+X$/.text(x); // ok
92+
}

0 commit comments

Comments
 (0)