Repository navigation
Conversation
content-encoding can show up as a list like "sdch, gzip" and decode() was just doing one dict lookup on the whole string which threw KeyError and then a LookupError. now we split on commas and run each codec in order, reversed for decode since that undoes them in the right order. sdch isn't something we actually support so it just passes through like identity. fixes mitmproxy#2246.
individual_coverage was sitting at 99% cause the sdch no-op on encode never got hit, only the decode one. add a quick assert for it.
Author
|
ci was just individual_coverage, the sdch no-op on the encode side never got exercised so encoding.py sat at 99%. added a one line assert covering it, green now |
2 tasks done
This branch has not been deployed
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.
Content-Encoding can technically be a list like "sdch, gzip", and right now decode just does one dict lookup on the whole string and blows up with a KeyError/LookupError. so if a server sends something like that, decoding the body throws instead of working.
fixed it by splitting on commas and applying each codec in turn (reverse order for decode, forward for encode). also treat sdch as identity since we never actually decode it and it was the thing tripping people up here. went with handling it in encoding.py per the thread where mhils said we should just deal with this.
added a test covering the sdch, gzip case plus whitespace and casing, full suite passes locally. closes #2246