diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-01-27 12:24:03 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-01-27 12:24:03 -0800 |
commit | 5a2e26d2b0b554bfcd6875a968bcd8090b7f9b03 (patch) | |
tree | 7ab6f053294cda0c1c01b2c58b980f2513c239a8 /redis/connection.py | |
parent | 04ddd34ec55a659b5bb8c1ac8c47899781b90a6d (diff) | |
download | redis-py-5a2e26d2b0b554bfcd6875a968bcd8090b7f9b03.tar.gz |
Connection URLs must have a valid scheme.
Fixes #969
Fixes #961
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/redis/connection.py b/redis/connection.py index cf5ed0e..0d1c394 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -885,7 +885,7 @@ class ConnectionPool(object): path = url.path hostname = url.hostname - # We only support redis:// and unix:// schemes. + # We only support redis://, rediss:// and unix:// schemes. if url.scheme == 'unix': url_options.update({ 'password': password, @@ -893,7 +893,7 @@ class ConnectionPool(object): 'connection_class': UnixDomainSocketConnection, }) - else: + elif url.scheme in ('redis', 'rediss'): url_options.update({ 'host': hostname, 'port': int(url.port or 6379), @@ -910,6 +910,10 @@ class ConnectionPool(object): if url.scheme == 'rediss': url_options['connection_class'] = SSLConnection + else: + valid_schemes = ', '.join(('redis://', 'rediss://', 'unix://')) + raise ValueError('Redis URL must specify one of the following' + 'schemes (%s)' % valid_schemes) # last shot at the db value url_options['db'] = int(url_options.get('db', db or 0)) |