Commit 4fd0441
authored
fix: clear the last polynomial-redos instance in swift-cache (#1549)
* fix: clear the last polynomial-redos instance in swift-cache
sanitizeCacheName used /^-+|-+$/g to trim edge dashes, the same
js/polynomial-redos pattern PR #1546 retired everywhere else. Replace
it with the linear-time trim used there, and add a counterfactual
regression test that fails against the old regex on a long interior
dash run.
* fix: keep sanitizeCacheName private, drive redos/fallback pins through compileSwiftSourceText
Addresses PR #1549 reviewer feedback: sanitizeCacheName was exported
solely so the regression test could import it, which docs/agents/testing.md's
test-interface rule forbids. Reverted the export and rewrote the test to
exercise the sanitizer through compileSwiftSourceText, an existing production
seam that already calls it.
- Timing pin: a cache name with a 100k-char interior dash run still resolves
in sub-second time (the call may reject once it reaches disk I/O due to the
OS path-component length limit, but that happens only after the now-fast
sanitize step, so timing the settle either way still proves no catastrophic
backtracking).
- Fallback pin: a cache name that sanitizes to nothing (e.g. '---') still
produces the 'swift-helper' fallback, observed via the returned executable
path.
Counterfactuals (see PR comment for full output):
- Restoring the retired `/^-+|-+$/g` regex trim made the timing pin fail:
3428ms >= 1000ms.
- Removing the `|| 'swift-helper'` fallback made the fallback pin fail:
basename did not start with 'swift-helper-'.1 parent 60400d0 commit 4fd0441
2 files changed
Lines changed: 42 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
103 | 130 | | |
104 | 131 | | |
105 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
173 | 186 | | |
174 | 187 | | |
175 | 188 | | |
| |||
0 commit comments