mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 04:17:31 +09:00
Issue #1302 followup - Add spec-compliance checks/errors
- Check for undefined/null regex flags (because...) - Make it throw a typeerror instead of syntax error on non-global - Generalize JS error messages for these checks.
This commit is contained in:
parent
2f3a6a58b4
commit
37e3ac713b
2 changed files with 7 additions and 2 deletions
|
|
@ -1042,6 +1042,9 @@ function RegExpMatchAll(string) {
|
|||
// Step 2.
|
||||
if (!IsObject(rx))
|
||||
ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, rx === null ? "null" : typeof rx);
|
||||
|
||||
if (rx.flags === undefined || rx.flags === null)
|
||||
ThrowTypeError(JSMSG_FLAGS_UNDEFINED_OR_NULL);
|
||||
|
||||
// Step 3.
|
||||
var str = ToString(string);
|
||||
|
|
@ -1052,9 +1055,9 @@ function RegExpMatchAll(string) {
|
|||
// Step 5.
|
||||
var flags = ToString(rx.flags);
|
||||
|
||||
// Step 2.b.iii; located here because it needs |flags|.
|
||||
// Step 2.b.iii; located here because it needs to check |flags|.
|
||||
if (!callFunction(std_String_includes, flags, "g")) {
|
||||
ThrowTypeError(JSMSG_BAD_REGEXP_FLAG, "- matchAll requires g");
|
||||
ThrowTypeError(JSMSG_REQUIRES_GLOBAL_REGEXP, "matchAll");
|
||||
}
|
||||
|
||||
// Step 6.
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ MSG_DEF(JSMSG_INVALID_NORMALIZE_FORM, 0, JSEXN_RANGEERR, "form must be one of '
|
|||
MSG_DEF(JSMSG_NEGATIVE_REPETITION_COUNT, 0, JSEXN_RANGEERR, "repeat count must be non-negative")
|
||||
MSG_DEF(JSMSG_NOT_A_CODEPOINT, 1, JSEXN_RANGEERR, "{0} is not a valid code point")
|
||||
MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
|
||||
MSG_DEF(JSMSG_FLAGS_UNDEFINED_OR_NULL, 0, JSEXN_TYPEERR, "'flags' property must neither be undefined nor null")
|
||||
MSG_DEF(JSMSG_REQUIRES_GLOBAL_REGEXP, 1, JSEXN_TYPEERR, "{0} must be called with a global RegExp")
|
||||
|
||||
// Number
|
||||
MSG_DEF(JSMSG_BAD_RADIX, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue