Commit 5654959
authored
Fix token and uri parsers to disallow empty results (#111)
This fixes cases where the parser would accept non-compliant request lines including empty methods
and paths.
For the `token` grammar, [the spec][spec-token] is:
```
token = 1*tchar
```
`1*` is shorthand for one-or-more, so the empty string is not a valid `token`.
For the path component of the request line, [the spec][spec-path] we're concerned with the
`absolute-path` grammar:
```
absolute-path = 1*( "/" segment )
```
While `segment` might be empty, there must be at least a `"/"` for it to be syntactically valid.
I've added tests for these cases and their combination, and had to update the expected error of one
of the existing URI tests which now fails sooner due to the empty path.
[spec-token]: https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#tokens
[spec-path]: https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#uri.references1 parent 6f6ff10 commit 5654959
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
663 | 669 | | |
664 | 670 | | |
665 | 671 | | |
| |||
675 | 681 | | |
676 | 682 | | |
677 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
678 | 690 | | |
679 | 691 | | |
680 | 692 | | |
| |||
1310 | 1322 | | |
1311 | 1323 | | |
1312 | 1324 | | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1313 | 1346 | | |
1314 | 1347 | | |
1315 | 1348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
0 commit comments