You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (codePointToSet != INVALID_CODEPOINT || prevprevWasACharSetAndPartOfRange)
2203
2206
{
2204
-
if (unicodeFlagPresent && prevprevWasACharSetAndPartOfRange)
2205
-
{
2206
-
Fail(JSERR_UnicodeRegExpRangeContainsCharClass);
2207
-
}
2208
-
elseif (prevprevWasACharSetAndPartOfRange)
2207
+
if (prevprevWasACharSetAndPartOfRange)
2209
2208
{
2209
+
//We a range containing a character class and the unicode flag is present, thus we end up having to throw a "Syntax" error here
2210
+
//This breaks the notion of Pass0 check for valid syntax, because during that time, the unicode flag is unknown.
2211
+
if (unicodeFlagPresent)
2212
+
{
2213
+
Fail(JSERR_UnicodeRegExpRangeContainsCharClass);
2214
+
}
2215
+
2210
2216
if (pendingCodePoint != INVALID_CODEPOINT)
2211
2217
{
2212
2218
codePointSet.Set(ctAllocator, pendingCodePoint);
2213
2219
}
2214
2220
2215
-
codePointSet.Set(ctAllocator, '-');
2221
+
codePointSet.Set(ctAllocator, '-');//Add '-' to set because a range was detected but turned out to be a union of character set with '-' and another atom.
RT_ERROR_MSG(JSERR_RegExpTooManyCapturingGroups, 5675, "", "Regular expression cannot have more than 32,767 capturing groups", kjstRangeError, 0)
368
368
RT_ERROR_MSG(JSERR_ProxyHandlerReturnedFalse, 5676, "Proxy %s handler returned false", "Proxy handler returned false", kjstTypeError, 0)
369
-
RT_ERROR_MSG(JSERR_UnicodeRegExpRangeContainsCharClass, 5677, "", "Character classes not allowed in class ranges", kjstSyntaxError, 0)
369
+
RT_ERROR_MSG(JSERR_UnicodeRegExpRangeContainsCharClass, 5677, "%s", "Character classes not allowed in a RegExp class range.", kjstSyntaxError, 0)
370
370
371
371
//Host errors
372
372
RT_ERROR_MSG(JSERR_HostMaybeMissingPromiseContinuationCallback, 5700, "", "Host may not have set any promise continuation callback. Promises may not be executed.", kjstTypeError, 0)
Copy file name to clipboardExpand all lines: test/Regex/characterclass_with_range.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,9 @@ var tests = [
58
58
matchRegExp("g",reUnicode,null);
59
59
matchRegExp("\u2028",reUnicode,null);
60
60
matchRegExp("\u2009",reUnicode,null);
61
-
assert.throws(()=>eval("/^[\\s-z]$/u.exec(\"-\")"),SyntaxError,"Expected an error due to character sets not being allowed in ranges when unicode flag is set.","Character classes not allowed in class ranges");
61
+
assert.throws(()=>eval("/^[\\s-z]$/u.exec(\"-\")"),SyntaxError,"Expected an error due to character sets not being allowed in ranges when unicode flag is set.","Character classes not allowed in a RegExp class range.");
62
+
assert.throws(()=>eval("/^[z-\\s]$/u.exec(\"-\")"),SyntaxError,"Expected an error due to character sets not being allowed in ranges when unicode flag is set.","Character classes not allowed in a RegExp class range.");
0 commit comments