@@ -554,9 +554,9 @@ class RegExp extends Expr instanceof StringLiteral {
554554 or
555555 this .negativeAssertionGroup ( start , end )
556556 or
557- this .positiveLookaheadAssertionGroup ( start , end )
557+ this .positiveLookaheadAssertionGroup ( start , end , _ , _ )
558558 or
559- this .positiveLookbehindAssertionGroup ( start , end )
559+ this .positiveLookbehindAssertionGroup ( start , end , _ , _ )
560560 }
561561
562562 /** Holds if an empty group is found between `start` and `end`. */
@@ -572,15 +572,15 @@ class RegExp extends Expr instanceof StringLiteral {
572572 or
573573 this .negativeAssertionGroup ( start , end )
574574 or
575- this .positiveLookaheadAssertionGroup ( start , end )
575+ this .positiveLookaheadAssertionGroup ( start , end , _ , _ )
576576 }
577577
578578 private predicate emptyMatchAtEndGroup ( int start , int end ) {
579579 this .emptyGroup ( start , end )
580580 or
581581 this .negativeAssertionGroup ( start , end )
582582 or
583- this .positiveLookbehindAssertionGroup ( start , end )
583+ this .positiveLookbehindAssertionGroup ( start , end , _ , _ )
584584 }
585585
586586 private predicate negativeAssertionGroup ( int start , int end ) {
@@ -593,32 +593,40 @@ class RegExp extends Expr instanceof StringLiteral {
593593 )
594594 }
595595
596- /** Holds if a negative lookahead is found between `start` and `end` */
597- predicate negativeLookaheadAssertionGroup ( int start , int end ) {
598- exists ( int in_start | this .negative_lookahead_assertion_start ( start , in_start ) |
599- this .groupContents ( start , end , in_start , _)
600- )
596+ /**
597+ * Holds if a negative lookahead is found between `start` and `end`, with contents
598+ * between `in_start` and `in_end`.
599+ */
600+ predicate negativeLookaheadAssertionGroup ( int start , int end , int in_start , int in_end ) {
601+ this .negative_lookahead_assertion_start ( start , in_start ) and
602+ this .groupContents ( start , end , in_start , in_end )
601603 }
602604
603- /** Holds if a negative lookbehind is found between `start` and `end` */
604- predicate negativeLookbehindAssertionGroup ( int start , int end ) {
605- exists ( int in_start | this .negative_lookbehind_assertion_start ( start , in_start ) |
606- this .groupContents ( start , end , in_start , _)
607- )
605+ /**
606+ * Holds if a negative lookbehind is found between `start` and `end`, with contents
607+ * between `in_start` and `in_end`.
608+ */
609+ predicate negativeLookbehindAssertionGroup ( int start , int end , int in_start , int in_end ) {
610+ this .negative_lookbehind_assertion_start ( start , in_start ) and
611+ this .groupContents ( start , end , in_start , in_end )
608612 }
609613
610- /** Holds if a positive lookahead is found between `start` and `end` */
611- predicate positiveLookaheadAssertionGroup ( int start , int end ) {
612- exists ( int in_start | this .lookahead_assertion_start ( start , in_start ) |
613- this .groupContents ( start , end , in_start , _)
614- )
614+ /**
615+ * Holds if a positive lookahead is found between `start` and `end`, with contents
616+ * between `in_start` and `in_end`.
617+ */
618+ predicate positiveLookaheadAssertionGroup ( int start , int end , int in_start , int in_end ) {
619+ this .lookahead_assertion_start ( start , in_start ) and
620+ this .groupContents ( start , end , in_start , in_end )
615621 }
616622
617- /** Holds if a positive lookbehind is found between `start` and `end` */
618- predicate positiveLookbehindAssertionGroup ( int start , int end ) {
619- exists ( int in_start | this .lookbehind_assertion_start ( start , in_start ) |
620- this .groupContents ( start , end , in_start , _)
621- )
623+ /**
624+ * Holds if a positive lookbehind is found between `start` and `end`, with contents
625+ * between `in_start` and `in_end`.
626+ */
627+ predicate positiveLookbehindAssertionGroup ( int start , int end , int in_start , int in_end ) {
628+ this .lookbehind_assertion_start ( start , in_start ) and
629+ this .groupContents ( start , end , in_start , in_end )
622630 }
623631
624632 private predicate group_start ( int start , int end ) {
@@ -1049,6 +1057,13 @@ class RegExp extends Expr instanceof StringLiteral {
10491057 or
10501058 this .alternationOption ( x , y , start , end )
10511059 )
1060+ or
1061+ // Lookbehind assertions can potentially match the start of the string
1062+ (
1063+ this .positiveLookbehindAssertionGroup ( _, _, start , _) or
1064+ this .negativeLookbehindAssertionGroup ( _, _, start , _)
1065+ ) and
1066+ this .item ( start , end )
10521067 }
10531068
10541069 /** A part of the regex that may match the end of the string. */
@@ -1074,6 +1089,13 @@ class RegExp extends Expr instanceof StringLiteral {
10741089 or
10751090 this .alternationOption ( x , y , start , end )
10761091 )
1092+ or
1093+ // Lookahead assertions can potentially match the end of the string
1094+ (
1095+ this .positiveLookaheadAssertionGroup ( _, _, _, end ) or
1096+ this .negativeLookaheadAssertionGroup ( _, _, _, end )
1097+ ) and
1098+ this .item ( start , end )
10771099 }
10781100
10791101 /**
0 commit comments