Skip to content

Commit 15b5658

Browse files
committed
update inefficientStringComparison, to avoid underscores
1 parent 036d749 commit 15b5658

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ql/src/codeql_ql/performance/InefficientStringComparisonQuery.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class RegexpMatchPredicate extends BuiltinPredicate {
4545
predicate canUseMatchInsteadOfRegexpMatch(Call c, string matchesStr) {
4646
c.getTarget() instanceof RegexpMatchPredicate and
4747
exists(string raw | raw = c.getArgument(0).(String).getValue() |
48-
matchesStr = "%" + raw.regexpCapture("^\\.\\*(\\w+)$", _)
48+
matchesStr = "%" + raw.regexpCapture("^\\.\\*([a-zA-Z\\d\\s-]+)$", _)
4949
or
50-
matchesStr = raw.regexpCapture("^(\\w+)\\.\\*$", _) + "%"
50+
matchesStr = raw.regexpCapture("^([a-zA-Z\\d\\s-]+)\\.\\*$", _) + "%"
5151
or
52-
matchesStr = "%" + raw.regexpCapture("^\\.\\*(\\w+)\\.\\*$", _) + "%"
52+
matchesStr = "%" + raw.regexpCapture("^\\.\\*([a-zA-Z\\d\\s-]+)\\.\\*$", _) + "%"
5353
)
5454
}

0 commit comments

Comments
 (0)