Conversation
follow RFC 9110, discarding invalid parts 2-3 times faster disallow arbitrary encodings handle encoded quotes for HTTP headers and multipart form data Co-authored-by: L. Kärkkäinen <98187+Tronic@users.noreply.github.com>
This was referenced Mar 6, 2023
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Based on the implementation @Tronic shared in #1628, I've refactored
parse_options_header. The new implementation is 2-3 times faster. The parser now does an initial pass for valid; key=valueparts, then does two simpler checks for continuation and charset markers on each key.This parses parameters that are valid according to RFC 9110. Some invalid values were previously accepted, such as
key,key=, andkey = value(spaces around equals). Invalid parts are ignored.This updates the parsing of quoted strings to handle both
\"escaping in HTTP headers and%22in multipart form data.We already handled RFC 2231 continuation and charset markers, however I don't think either feature is sent by modern clients. Only UTF-8, ASCII, and ISO-8859-1 charsets are accepted, others are left quoted.
Removed the remnants of the
multiple=Trueflag that was removed earlier.fixes #1628