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
//We a range containing a character class and the unicode flag is present, thus we end up having to throw a "Syntax" error here
2215
+
//A range containing a character class and the unicode flag is present, thus we end up having to throw a "Syntax" error here
2216
2216
//This breaks the notion of Pass0 check for valid syntax, because during that time, the unicode flag is unknown.
2217
2217
if (unicodeFlagPresent)
2218
2218
{
@@ -2500,7 +2500,7 @@ namespace UnifiedRegex
2500
2500
}
2501
2501
else
2502
2502
{
2503
-
DeferredFailIfUnicode(JSERR_RegExpInvalidEscape); // Fail in unicode mode for non-letter escaped control characters according to 262 Annex-B RegExp grammar SPEC #prod-annexB-Term
2503
+
DeferredFailIfUnicode(JSERR_RegExpInvalidEscape); // Fail in unicode mode for non-letter escaped control characters according to 262 Annex-B RegExp grammar spec #prod-annexB-Term
re=/[\czA]+/u;//'z' = ascii x7A, parsed as [\x1AA]+
136
130
matchRegExp("abcdefghi",re,null);
137
131
matchRegExp("\\\\",re,null);
138
132
matchRegExp("////",re,null);
139
133
matchRegExp("YZA\x1aABC",re,"A\x1aA");
140
134
141
-
assert.throws(()=>eval("\"\".match(/[\\c]/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
135
+
assert.throws(()=>eval("\"\".match(/[\\c]/u)"),SyntaxError,"(Character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by no character here.",
142
136
"Invalid regular expression: invalid escape in unicode pattern");
143
-
assert.throws(()=>eval("\"\".match(/[\\c-d]/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
137
+
assert.throws(()=>eval("\"\".match(/[\\c-d]/u)"),SyntaxError,"(Character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a dash, '-', here.",
144
138
"Invalid regular expression: invalid escape in unicode pattern");
145
-
assert.throws(()=>eval("\"\".match(/[ab\\c_$]/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
139
+
assert.throws(()=>eval("\"\".match(/[ab\\c_$]/u)"),SyntaxError,"(Character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by an underscore, '_', here.",
146
140
"Invalid regular expression: invalid escape in unicode pattern");
147
-
assert.throws(()=>eval("\"\".match(/[ab\\c\\d]/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
141
+
assert.throws(()=>eval("\"\".match(/[ab\\c\\d]/u)"),SyntaxError,"(Character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a backslash, '\\', here.",
148
142
"Invalid regular expression: invalid escape in unicode pattern");
149
-
assert.throws(()=>eval("\"\".match(/[ab\\c3]/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
143
+
assert.throws(()=>eval("\"\".match(/[ab\\c3]/u)"),SyntaxError,"(Character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a number, '3', here.",
150
144
"Invalid regular expression: invalid escape in unicode pattern");
151
145
152
-
re=/\cAg/u;//'A' = ascii x41
146
+
re=/\cAg/u;//'A' = ascii x41, parsed as "\x01g"
153
147
matchRegExp("abcdefghi",re,null);
154
148
matchRegExp("\\\\",re,null);
155
149
matchRegExp("////",re,null);
156
150
matchRegExp("\x01\x01gg\x02\x04ggg",re,"\x01g");
157
151
158
-
re=/\czA/u;//'z' = ascii x7A
152
+
re=/\czA/u;//'z' = ascii x7A, parsed as "\x1aA"
159
153
matchRegExp("abcdefghi",re,null);
160
154
matchRegExp("\\\\",re,null);
161
155
matchRegExp("////",re,null);
162
156
matchRegExp("YZA\x1aABC",re,"\x1aA");
163
157
164
-
assert.throws(()=>eval("\"\".match(/\\c/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
158
+
assert.throws(()=>eval("\"\".match(/\\c/u)"),SyntaxError,"(Non-character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by no character here.",
165
159
"Invalid regular expression: invalid escape in unicode pattern");
166
-
assert.throws(()=>eval("\"\".match(/\\c-d/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
160
+
assert.throws(()=>eval("\"\".match(/\\c-d/u)"),SyntaxError,"(Non-character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a dash, '-', here.",
167
161
"Invalid regular expression: invalid escape in unicode pattern");
168
-
assert.throws(()=>eval("\"\".match(/ab\\c_$/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
162
+
assert.throws(()=>eval("\"\".match(/ab\\c_$/u)"),SyntaxError,"(Non-character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by an underscore, '_', here.",
169
163
"Invalid regular expression: invalid escape in unicode pattern");
170
-
assert.throws(()=>eval("\"\".match(/ab\\c\\d/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
164
+
assert.throws(()=>eval("\"\".match(/ab\\c\\d/u)"),SyntaxError,"(Non-character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a backslash, '\\', here.",
171
165
"Invalid regular expression: invalid escape in unicode pattern");
172
-
assert.throws(()=>eval("\"\".match(/ab\\c3/u)"),SyntaxError,"Expected an error due to non-letters being disallowed from control character when unicode flag present",
166
+
assert.throws(()=>eval("\"\".match(/ab\\c3/u)"),SyntaxError,"(Non-character class) Expected an error because escaped c must be followed by a letter when unicode flag is present, but is followed by a number, '3', here.",
173
167
"Invalid regular expression: invalid escape in unicode pattern");
174
168
}
175
169
},
176
170
{
177
171
name : "Control character edge cases",
178
172
body : function()
179
173
{
180
-
re=/[\c-g]+/;//'-' = ascii x2D
174
+
re=/[\c-g]+/;//'-' = ascii x2D, parsed as [\\c-g]+
0 commit comments