-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix token and uri parsers to disallow empty results #111
Merged
seanmonstar
merged 1 commit into
seanmonstar:master
from
acfoltzer:acfoltzer/empty-methods-paths
Mar 18, 2022
Merged
Fix token and uri parsers to disallow empty results #111
seanmonstar
merged 1 commit into
seanmonstar:master
from
acfoltzer:acfoltzer/empty-methods-paths
Mar 18, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acfoltzer
commented
Mar 16, 2022
This appears to be performance neutral:
(tested with Ubuntu 20.04 on a 18C/36T Xeon) |
Criterion shows this to be within the noise after much more sampling, so I feel increasingly confident this is a performance-neutral fix
|
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
acfoltzer
force-pushed
the
acfoltzer/empty-methods-paths
branch
from
March 18, 2022 17:12
615f4be
to
442e2e2
Compare
seanmonstar
approved these changes
Mar 18, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean, thanks for the bench results!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes cases where the parser would accept non-compliant request lines including empty methods and paths.
For the
token
grammar, the spec is:1*
is shorthand for one-or-more, so the empty string is not a validtoken
.For the path component of the request line, the spec we're concerned with the
absolute-path
grammar: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.