Skip to content

Commit 6b5cce0

Browse files
Jami CogswellJami Cogswell
Jami Cogswell
authored and
Jami Cogswell
committed
Java: regexpMatch back to matches for readability
1 parent e0391b7 commit 6b5cce0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: java/ql/lib/semmle/code/java/security/PathSanitizer.qll

+2-4
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ private predicate isSingleReplaceAll(StringReplaceAllCall replaceAllCall) {
427427
or
428428
targetValue.matches("%|%") and
429429
target.getStringValue().matches("%" + ["\\.\\.", "[.][.]", "\\."] + "%") and
430-
//targetValue.regexpMatch(".*(\\\\\\.\\\\\\.|\\[.\\]\\[.\\]|\\\\\\.).*") and
431430
targetValue.matches("%/%") and
432431
targetValue.matches("%\\\\\\\\%")
433432
)
@@ -492,13 +491,12 @@ private predicate isMatchesCall(StringMatchesCall matchesCall, Expr checkedExpr,
492491
target.getStringValue() = targetValue and
493492
checkedExpr = matchesCall.getQualifier()
494493
|
495-
targetValue.regexpMatch("\\[(.*)\\]([*+]|\\{.*\\})") and
494+
target.getStringValue().matches(["[%]*", "[%]+", "[%]{%}"]) and
496495
(
497496
// Allow anything except `.`, '/', '\'
498497
(
499498
// Note: we do not account for when '.', '/', '\' are inside a character range
500-
// not targetValue.matches("[%" + [".", "/", "\\\\"] + "%]%") and
501-
not targetValue.regexpMatch("\\[.*(\\.|\\\\|/).*\\].*") and
499+
not targetValue.matches("[%" + [".", "/", "\\\\"] + "%]%") and
502500
not targetValue.matches("%[^%]%")
503501
or
504502
targetValue.matches("[^%.%]%") and

0 commit comments

Comments
 (0)