Commit 515b951
committed
fix(github): permit a whitespace-only path component
safeUrlPath rejected a path component made only of spaces. That check had no
security value and a real cost: git tracks both a file and a directory whose
entire name is spaces, so a valid GitHub file could not be read, updated, or
deleted.
A whitespace-only segment is not a dot segment, and the parser never removes it:
new URL('https://x/a/%20%20%20/b').pathname => /a/%20%20%20/b (kept)
new URL('https://x/a/../b').pathname => /b (removed)
Only a truly empty component (a `//`, where the caller wrote no name at all) is
rejected now. Dot-segment and backslash rejection are unchanged.
safeUrlPathSegment still rejects an all-whitespace value. That asymmetry is
correct: it trims opaque ids first, so one made only of spaces has named
nothing.
The TSDoc records why the check is absent, citing the git paths and the parser
behaviour, so it is not restored on aesthetic grounds.1 parent 64273cf commit 515b951
3 files changed
Lines changed: 58 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
382 | 402 | | |
383 | 403 | | |
384 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
247 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
248 | 273 | | |
249 | 274 | | |
250 | 275 | | |
| |||
271 | 296 | | |
272 | 297 | | |
273 | 298 | | |
274 | | - | |
| 299 | + | |
275 | 300 | | |
276 | 301 | | |
277 | 302 | | |
| |||
288 | 313 | | |
289 | 314 | | |
290 | 315 | | |
291 | | - | |
292 | | - | |
| 316 | + | |
| 317 | + | |
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
| |||
0 commit comments