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
commit 17087ac4a2
Notes: sideshowbarker 2024-07-17 05:21:12 +09:00
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
});