JS: invertCase -> toOtherCase

This commit is contained in:
Asger F
2022-06-28 10:07:57 +02:00
parent 3c9e743495
commit b1251f0c63

View File

@@ -16,7 +16,7 @@ import javascript
* Converts `s` to upper case, or to lower-case if it was already upper case.
*/
bindingset[s]
string invertCase(string s) {
string toOtherCase(string s) {
if s.regexpMatch(".*[a-z].*") then result = s.toUpperCase() else result = s.toLowerCase()
}
@@ -35,7 +35,7 @@ predicate isCaseSensitiveRegExp(RegExpTerm term) {
const = term.getAChild*() and
const.getValue().regexpMatch(".*[a-zA-Z].*") and
not getEnclosingClass(const).getAChild().(RegExpConstant).getValue() =
invertCase(const.getValue()) and
toOtherCase(const.getValue()) and
not const.getParent*() instanceof RegExpNegativeLookahead and
not const.getParent*() instanceof RegExpNegativeLookbehind
)
@@ -67,7 +67,7 @@ string getExampleString(RegExpTerm term) {
string getCaseSensitiveBypassExample(RegExpTerm term) {
exists(string example |
example = getExampleString(term) and
result = invertCase(example) and
result = toOtherCase(example) and
result != example // getting an example string is approximate; ensure we got a proper case-change example
)
}