1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:37:36 +00:00

LibJS: Unescape incorrectly escaped code units in regex patterns

We were translating the pattern [\⪾-\⫀] to [\\u2abe-\\u2ac0], which
is a very different pattern; as a code unit converted to the \uhhh
format has no meaning when escaped, this commit makes us simply skip
escaping it when translating the pattern.
This commit is contained in:
Ali Mohammad Pur 2023-09-16 16:03:54 +03:30 committed by Andreas Kling
parent 35ff38aaea
commit 17087ac4a2
2 changed files with 22 additions and 3 deletions

View file

@ -60,3 +60,9 @@ test("regexp literals are re-useable", () => {
expect(re.test("test")).toBeTrue();
}
});
test("Incorrectly escaped code units not converted to invalid patterns", () => {
const re = /[\⪾-\⫀]/;
expect(re.test("⫀")).toBeTrue();
expect(re.test("\\u2abe")).toBeFalse(); // ⫀ is \u2abe
});