mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibJS: Stop executing successful regex if it's past the end of the input
If the regex always matches the input, even if it's past the end, then
we need to stop execution of the regex when it's past the end. This
corresponds to step 13.a and prevents it from infinitely looping.
Reduced from: d98672060f/packages/react-i18n/src/utilities/money.ts (L10-L14)
This commit is contained in:
parent
f839f1b44b
commit
105096e75a
Notes:
github-actions[bot]
2025-02-16 08:23:29 +00:00
Author: https://github.com/Lubrsi
Commit: 105096e75a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3573
2 changed files with 7 additions and 1 deletions
|
@ -66,3 +66,9 @@ test("Incorrectly escaped code units not converted to invalid patterns", () => {
|
|||
expect(re.test("⫀")).toBeTrue();
|
||||
expect(re.test("\\u2abe")).toBeFalse(); // ⫀ is \u2abe
|
||||
});
|
||||
|
||||
test("regexp that always matches stops matching if it's past the end of the string instead of infinitely looping", () => {
|
||||
const re = new RegExp("[\u200E]*", "gu");
|
||||
expect("whf".match(re)).toEqual(["", "", "", ""]);
|
||||
expect(re.lastIndex).toBe(0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue