Skip to content

Commit 5c9601d

Browse files
razor-xseambot
andauthored
fix: Avoid edge case of slow regex (#245)
* fix: Avoid edge case of slow regex * ci: Format code --------- Co-authored-by: Seam Bot <[email protected]>
1 parent 5c7135b commit 5c9601d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/seam/connect/auth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,8 @@ export const warnOnInsecureuserIdentifierKey = (
269269
}
270270

271271
// SOURCE: https://stackoverflow.com/a/46181
272-
const isEmail = (value: string): boolean =>
273-
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
272+
const isEmail = (value: string): boolean => {
273+
if (value.includes('!')) return false
274+
// The regex may run slow on strings starting with '!@!.' and with many repetitions of '!.'.
275+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
276+
}

0 commit comments

Comments
 (0)