Repository navigation
fix(capture-kit): linear email-label check in repeated-nav detection - #3365
Conversation
Replace the polynomially backtracking /\S+@\S+\.\S+/ with a per-token indexOf/lastIndexOf check on the already whitespace-normalized label. Results are unchanged. Resolves code-scanning alert #47. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
|
I found no problems in e42bc0c. The linear email-label check in repeated-nav detection reads as equivalent to the old regex, and the colocated test covers the slow-input case. CI is green: all 19 checks pass, and the diff touches only repeated-nav-subtree.ts and its test. There are no conflicts, and nothing else stands between this and merge. I did not run the tests or the old regex locally. My read rests on the code and the CI result. The 300k-string fuzz and the 2-minute old-regex run are your numbers, and I did not reproduce them. The |
|
Summary
Fixes code-scanning alert #47 (
js/polynomial-redos, high).isEmailLikeLabelinrepeated-nav-subtree.tsran/\S+@\S+\.\S+/on accessibility text from the app under test. This runs during snapshot presentation, so a long label with the wrong shape (for example'@'.repeat(50_000)) could stall every snapshot.The label has already been trimmed and its whitespace collapsed to single spaces. The fix splits it on
' 'and checks each token in linear time. A token matches when it has an@at index ≥ 1 and a.after that@, with at least one character between the@and the.and at least one after the.. This is the same rule the regex applied to one whitespace-free run, so results don't change. There's no length cap and no suppression comment.2 files touched: the source module and its colocated test.
Validation
Tested commit: e42bc0c.
pnpm check:affected --run: all runnable checks passed (302 files, 2361 tests).'@'.repeat(50_000),'a@'.repeat(25_000), and others) finish in milliseconds. On the same'@'.repeat(50_000)input the old regex had not finished after more than 2 minutes.a@.found no mismatch with the old regex.🤖 Generated with Claude Code