File tree Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -1120,18 +1120,42 @@ namespace UnifiedRegex
1120
1120
if (!standardEncodedChars->IsDigit (ec))
1121
1121
{
1122
1122
if (digits == 0 )
1123
+ {
1123
1124
Fail (JSERR_RegExpSyntax);
1125
+ }
1126
+
1124
1127
return n;
1125
1128
}
1129
+
1126
1130
if (n > MaxCharCount / 10 )
1127
- Fail (JSERR_RegExpSyntax);
1131
+ {
1132
+ break ;
1133
+ }
1134
+
1128
1135
n *= 10 ;
1129
1136
if (n > MaxCharCount - standardEncodedChars->DigitValue (ec))
1130
- Fail (JSERR_RegExpSyntax);
1137
+ {
1138
+ break ;
1139
+ }
1140
+
1131
1141
n += standardEncodedChars->DigitValue (ec);
1132
1142
digits++;
1133
1143
ECConsume ();
1134
1144
}
1145
+
1146
+ Assert (digits != 0 ); // shouldn't be able to reach here with (digits == 0)
1147
+
1148
+ // The token had a value larger than MaxCharCount so we didn't return the value and reached here instead.
1149
+ // Consume the rest of the token and return MaxCharCount.
1150
+ while (true )
1151
+ {
1152
+ EncodedChar ec = ECLookahead ();
1153
+ if (!standardEncodedChars->IsDigit (ec))
1154
+ {
1155
+ return MaxCharCount;
1156
+ }
1157
+ ECConsume ();
1158
+ }
1135
1159
}
1136
1160
1137
1161
template <typename P, const bool IsLiteral>
Original file line number Diff line number Diff line change
1
+ //-------------------------------------------------------------------------------------------------------
2
+ // Copyright (C) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4
+ //-------------------------------------------------------------------------------------------------------
5
+
6
+ function assert ( b ) {
7
+ if ( ! b ) {
8
+ print ( 'fail' ) ;
9
+ }
10
+ }
11
+
12
+ let p1 = new RegExp ( '^[a-z]{2,2147483648}$' ) ;
13
+ assert ( ! p1 . test ( 'a' ) ) ;
14
+
15
+ let p2 = / ^ [ a - z ] { 2 , 2147483648 } $ / ;
16
+ assert ( p2 . test ( 'aaaaa' ) ) ;
17
+
18
+ print ( 'PASS' ) ;
Original file line number Diff line number Diff line change 37
37
<compile-flags >-ES6RegExPrototypeProperties-</compile-flags >
38
38
</default >
39
39
</test >
40
+ <test >
41
+ <default >
42
+ <files >clampNumericQuantifier.js</files >
43
+ </default >
44
+ </test >
40
45
<test >
41
46
<default >
42
47
<files >rx1.js</files >
You can’t perform that action at this time.
0 commit comments