Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.references
- Loading branch information