mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
stop spuriously matching everything when encountering an unsupported charclass
This commit is contained in:
@@ -451,7 +451,15 @@ module Make<RegexTreeViewSig TreeImpl> {
|
||||
}
|
||||
|
||||
bindingset[char]
|
||||
override predicate matches(string char) { not hasChildThatMatches(cc, char) }
|
||||
override predicate matches(string char) {
|
||||
not hasChildThatMatches(cc, char) and
|
||||
(
|
||||
// detect unsupported char classes that doesn't match anything (e.g. `\p{L}` in ruby), and don't report any matches
|
||||
exists(string c | hasChildThatMatches(cc, c))
|
||||
or
|
||||
not exists(cc.getAChild()) // [^] still matches everything
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,7 +544,9 @@ module Make<RegexTreeViewSig TreeImpl> {
|
||||
|
||||
bindingset[char]
|
||||
override predicate matches(string char) {
|
||||
not classEscapeMatches(charClass.toLowerCase(), char)
|
||||
not classEscapeMatches(charClass.toLowerCase(), char) and
|
||||
// detect unsupported char classes (e.g. `\p{L}` in ruby), and don't report any matches
|
||||
exists(string c | classEscapeMatches(charClass.toLowerCase(), c))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user