Skip to content

Commit 6fbf21a

Browse files
committed
JS: Sharpen up EnumerationRegExp
1 parent 93b1114 commit 6fbf21a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

javascript/ql/lib/semmle/javascript/MembershipCandidates.qll

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,17 @@ module MembershipCandidate {
140140
EnumerationRegExp() {
141141
this.isRootTerm() and
142142
RegExp::isFullyAnchoredTerm(this) and
143-
exists(RegExpTerm child | this.getAChild*() = child |
144-
child instanceof RegExpSequence or
145-
child instanceof RegExpCaret or
146-
child instanceof RegExpDollar or
147-
child instanceof RegExpConstant or
148-
child instanceof RegExpAlt or
149-
child instanceof RegExpGroup
150-
) and
151-
// exclude "length matches" that match every string
152-
not this.getAChild*() instanceof RegExpDot
143+
not exists(RegExpTerm child | child.getRootTerm() = this |
144+
child instanceof RegExpDot or
145+
child instanceof RegExpCharacterClass or
146+
child instanceof RegExpUnicodePropertyEscape
147+
)
153148
}
154149

155150
/**
156151
* Gets a string matched by this regular expression.
157152
*/
158-
string getAMember() { result = this.getAChild*().getAMatchedString() }
153+
string getAMember() { result = any(RegExpTerm t | t.getRootTerm() = this).getAMatchedString() }
159154
}
160155

161156
/**

0 commit comments

Comments
 (0)