mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:27:35 +00:00
LibJS: Convert matched regex result to string in Symbol.replace
This would crash on an undefined match (no match), since the matched result was assumed to be a string (such as on discord.com). The spec suggests converting it to a string as well: https://tc39.es/ecma262/#sec-regexp.prototype-@@replace (14#c)
This commit is contained in:
parent
358697a32f
commit
6cd318d784
2 changed files with 14 additions and 3 deletions
|
@ -148,3 +148,10 @@ test("empty character class semantics", () => {
|
|||
expect(res.length).toBe(1);
|
||||
expect(res[0]).toBe("x");
|
||||
});
|
||||
|
||||
// #6409
|
||||
test("undefined match result", () => {
|
||||
const r = /foo/;
|
||||
r.exec = () => ({});
|
||||
expect(r[Symbol.replace]()).toBe("undefined");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue