Speed up processing junk before or after first or last boundary#178
Closed
defnull wants to merge 2 commits intoKludex:masterfrom
Closed
Speed up processing junk before or after first or last boundary#178defnull wants to merge 2 commits intoKludex:masterfrom
defnull wants to merge 2 commits intoKludex:masterfrom
Conversation
Junk before the first or after the last boundary is permitted according to the specification, but should not trigger one log message per character. This patch removes the log lines, and also skips over all remaining bytes after the last boundary if possible.
Fail if there are more than 16 superfluous new-lines in front of the first boundary, as this indicates a broken or malicious client. The spec technically allows it, but no browser or http client should ever do that.
Contributor
Author
|
Tests pass, but I did not write new ones so coverage dropped to 99% |
Kludex
reviewed
Oct 28, 2024
|
|
||
| if state == MultipartState.START: | ||
| # Stop parsing if there is no boundary within the first chunk | ||
| if i == 16: |
Contributor
Author
There was a problem hiding this comment.
Yea, I'm not happy about that either. Two line breaks should be allowed, that's not that uncommon. More are uncommon, but who knows? It's just an arbitrary number between 2 and "too much to waste time on it". Maybe ignore the second commit for now and just remove the log lines?
Contributor
Author
There was a problem hiding this comment.
The comment is lying, I was first checking for i == length-1 but that broke tests. This needs more work I guess.
Contributor
Author
|
This is worked on in -> #189 now |
This file contains hidden or 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
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 should fix #162 by removing log lines that would trigger once per character of junk before or after the first or last boundary. The parser now skips over junk after the last boundary, and triggers an error if there is too much junk in front of the first boundary. You may want to cherry-pick only the first commit if you want to stay compliant to the specification, which requires junk to be accepted and ignored.