@@ -20,6 +20,12 @@ string invertCase(string s) {
2020 if s .regexpMatch ( ".*[a-z].*" ) then result = s .toUpperCase ( ) else result = s .toLowerCase ( )
2121}
2222
23+ RegExpCharacterClass getEnclosingClass ( RegExpTerm term ) {
24+ term = result .getAChild ( )
25+ or
26+ term = result .getAChild ( ) .( RegExpRange ) .getAChild ( )
27+ }
28+
2329/**
2430 * Holds if `term` distinguishes between upper and lower case letters, assuming the `i` flag is not present.
2531 */
@@ -28,7 +34,7 @@ predicate isCaseSensitiveRegExp(RegExpTerm term) {
2834 exists ( RegExpConstant const |
2935 const = term .getAChild * ( ) and
3036 const .getValue ( ) .regexpMatch ( ".*[a-zA-Z].*" ) and
31- not const . getParent ( ) . ( RegExpCharacterClass ) .getAChild ( ) .( RegExpConstant ) .getValue ( ) =
37+ not getEnclosingClass ( const ) .getAChild ( ) .( RegExpConstant ) .getValue ( ) =
3238 invertCase ( const .getValue ( ) ) and
3339 not const .getParent * ( ) instanceof RegExpNegativeLookahead and
3440 not const .getParent * ( ) instanceof RegExpNegativeLookbehind
@@ -59,8 +65,11 @@ string getExampleString(RegExpTerm term) {
5965}
6066
6167string getCaseSensitiveBypassExample ( RegExpTerm term ) {
62- result = invertCase ( getExampleString ( term ) ) and
63- result != ""
68+ exists ( string example |
69+ example = getExampleString ( term ) and
70+ result = invertCase ( example ) and
71+ result != example // getting an example string is approximate; ensure we got a proper case-change example
72+ )
6473}
6574
6675/**
@@ -83,7 +92,7 @@ predicate isCaseSensitiveMiddleware(
8392 isCaseSensitiveRegExp ( regexp .getRoot ( ) ) and
8493 exists ( string flags |
8594 flags = regexp .getFlags ( ) and
86- not flags . matches ( "%i%" )
95+ not RegExp :: isIgnoreCase ( flags )
8796 )
8897 )
8998}
0 commit comments