Repository navigation
Commit 9b71e34
fix(shared): bound the file-link label so bracket runs stop rescanning
FILE_LINK_TOKEN_REGEX let the label body repeat without a bound. Every
whitespace in the composer is therefore a candidate start: the engine
scans the rest of the text for a closing "]", fails, and rescans from
the next whitespace. On a run of unterminated brackets that is
quadratic, and collectComposerInlineTokens runs on raw composer text,
so pasting one freezes the tab.
Capping the body makes each attempt constant-bounded:
120k chars of " [[" 2838ms -> 33ms
60k chars 676ms -> 17ms
30k chars 167ms -> 8ms
The cap cannot reject a link anyone could meaningfully write. Only a
basename survives the `label !== basename` check below it, and the
longest filename common filesystems allow is 255.
Verified equivalent to the old pattern over 156,504 generated inputs
built from [ ] ( ) \ @ " whitespace and path-ish fragments, comparing
match count, offsets and every capture group: zero differences. The
single intended difference is at the cap itself, which the two new
boundary tests pin.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent 05eb051 commit 9b71e34
2 files changed
Lines changed: 36 additions & 1 deletion
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
132 | 153 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
| |||
0 commit comments