Improve performance of query filters (especially on large bodies) #1839
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.
Fixes: #1838
Rewrite two
QueryFilter
s with an implementation based onStringTokenizer
rather than a possibleO(n^2)
regex (for more information see the linked issue).Description
I've looked at the description for a
application/x-www-form-urlencoded
encoded body here: https://url.spec.whatwg.org/#urlencoded-parsing and tried to follow those lines. I did not put in the percentage encoding, since that wasn't in the current implementation and I didn't want to break backwards compatibility.I've added a few test cases that weren't covered (and also not all handled correctly in the previous implementation), but I think they are rather obscure. Where normally you have
key=value
, it's also possible to just havekey
, if there is no=
there,key
is treated as the key and there is no value. Alsokey=
and=value
are allowed even, resulting in an empty key or empty value respectively.Motivation and Context
Fixes #1838
Types of changes
Checklist: