From 8ed3676b5f3a50c5e2742b642ffb0db7bd6af085 Mon Sep 17 00:00:00 2001 From: Tom Jenkinson Date: Sat, 21 Oct 2023 21:30:22 +0100 Subject: [PATCH] Do not support the `s` flag --- src/redos-detector.test.ts | 2 +- src/redos-detector.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/redos-detector.test.ts b/src/redos-detector.test.ts index 2030ba3f..487d1290 100644 --- a/src/redos-detector.test.ts +++ b/src/redos-detector.test.ts @@ -599,7 +599,7 @@ describe('RedosDetector', () => { expect(() => isSafe(/a/m)).toThrowError('Unsupported flag: m'); }); - ['u', 'g', 's', 'y', 'i'].forEach((flag) => { + ['u', 'g', 'y', 'i'].forEach((flag) => { it(`supports the "${flag}" flag`, () => { expect(() => isSafe(new RegExp('a', flag))).not.toThrowError(); }); diff --git a/src/redos-detector.ts b/src/redos-detector.ts index f527e8c8..9ebfd322 100644 --- a/src/redos-detector.ts +++ b/src/redos-detector.ts @@ -226,13 +226,7 @@ export const defaultMaxBacktracks = 200; export const defaultMaxSteps = 20000; export const defaultUnicode = false; export const defaultCaseInsensitive = false; -const supportedJSFlags: ReadonlySet = new Set([ - 'u', - 'g', - 's', - 'y', - 'i', -]); +const supportedJSFlags: ReadonlySet = new Set(['u', 'g', 'y', 'i']); type PatternWithAtomicGroupOffsets = Readonly<{ atomicGroupOffsets: ReadonlySet;