Handle percent-encoded URLs in parsing code #586
Merged
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.
Hi,
Clients of redis-py that attempt to instantiate a
ConnectionPool
object by using thefrom_url
class method can run into problems if components of the passed-in URL contain illegal characters (e.g.rediss://:my/password@localhost:6379
). Understandably the forward slash in this example URL causes it to be parsed incorrectly, but even if a client attempts to percent-encode their URL (e.g.rediss://:my%2Fpassword@localhost:6379
) this will not fix the problem sincefrom_url
will not know to decode the password after the URL is parsed.This commit attempts to fix the problem by introducing a new argument,
decode_components
, tofrom_url
that allows URL components to be decoded after the URL has been parsed. I used a flag here because existing clients might be relying on the current behavior.I added some unit tests and verified that they pass with python2 and python3.
This fixes issue #579
Thanks,
Paul