@@ -472,20 +472,27 @@ abstract class RegexString extends StringLiteral {
472472 )
473473 }
474474
475- private predicate flagGroupStart ( int start , int end , string c ) {
475+ private predicate flagGroupStart ( int start , int end ) {
476476 this .isGroupStart ( start ) and
477477 this .getChar ( start + 1 ) = "?" and
478- end = start + 3 and
479- c = this .getChar ( start + 2 ) and
480- c in [ "i" , "m" , "s" , "u" , "x" , "U" ]
478+ this .getChar ( start + 2 ) in [ "i" , "m" , "s" , "u" , "x" , "U" ] and
479+ end = start + 2
480+ }
481+
482+ private predicate flagGroup ( int start , int end , string c ) {
483+ exists ( int inStart , int inEnd |
484+ this .flagGroupStart ( start , inStart ) and
485+ this .groupContents ( start , end , inStart , inEnd ) and
486+ this .getChar ( [ inStart .. inEnd - 1 ] ) = c
487+ )
481488 }
482489
483490 /**
484491 * Gets the mode of this regular expression string if
485492 * it is defined by a prefix.
486493 */
487494 string getModeFromPrefix ( ) {
488- exists ( string c | this .flagGroupStart ( _, _, c ) |
495+ exists ( string c | this .flagGroup ( _, _, c ) |
489496 c = "i" and result = "IGNORECASE"
490497 or
491498 c = "m" and result = "MULTILINE"
@@ -540,7 +547,7 @@ abstract class RegexString extends StringLiteral {
540547 private predicate groupStart ( int start , int end ) {
541548 this .nonCapturingGroupStart ( start , end )
542549 or
543- this .flagGroupStart ( start , end , _ )
550+ this .flagGroupStart ( start , end )
544551 or
545552 this .namedGroupStart ( start , end )
546553 or
0 commit comments