Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions shared/regex/codeql/regex/nfa/NfaUtils.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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
hasChildThatMatches(cc, _)
or
not exists(cc.getAChild()) // [^] still matches everything
)
}
}

/**
Expand Down Expand Up @@ -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
classEscapeMatches(charClass.toLowerCase(), _)
}
}

Expand Down