mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
LibJS: Coerce named captures to an object before calling GetSubstitution
Per the spec, before invoking the GetSubstitution abstraction, the named capture groups (if not undefined) should be coerced to an object via the ToObject abstraction.
This commit is contained in:
parent
424c7eaa40
commit
8fcdc57ae1
2 changed files with 24 additions and 1 deletions
|
@ -399,7 +399,14 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
} else {
|
||||
replacement = get_substitution(global_object, matched, string, position, captures, named_captures, replace_value);
|
||||
auto named_captures_object = js_undefined();
|
||||
if (!named_captures.is_undefined()) {
|
||||
named_captures_object = named_captures.to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
||||
replacement = get_substitution(global_object, matched, string, position, captures, named_captures_object, replace_value);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue