Repository navigation
Commit 120d2e2
committed
fix(compiler): prevent ReDoS in i18n placeholder name extraction
The regex that reads the name from a `//i18n(ph="NAME")` annotation on an
interpolation expression chained five greedy `[\s\S]*` segments between the
literals `i18n`, `(`, `ph`, `=` and the opening quote. When the prefix
matches but the closing quote/paren is missing, a run of `i18n(ph=` text can be
split across those wildcards in many ways, so the match backtracks
catastrophically (`'//' + 'i18n(ph='.repeat(200)`, ~1.6 KB, takes ~96s).
The separators in that annotation are only ever whitespace, so bind them to
`\s*` and stop the name at the delimiter quote. Valid annotations are still
recognized identically; the match is now linear.1 parent 3bf2430 commit 120d2e2
2 files changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
457 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
458 | 461 | | |
459 | 462 | | |
460 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
150 | 161 | | |
151 | 162 | | |
152 | 163 | | |
| |||
0 commit comments