Skip to content

Commit 1f80e14

Browse files
committed
encode connection URL #65
1 parent 5925e25 commit 1f80e14

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pgsync/utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import threading
66
import time
77
from datetime import timedelta
8+
from urllib.parse import quote_plus
89

910
from six import string_types
1011

@@ -252,7 +253,7 @@ def get_elasticsearch_url(
252253
user = user or ELASTICSEARCH_USER
253254
password = password or ELASTICSEARCH_PASSWORD
254255
if user:
255-
return f'{scheme}://{user}:{password}@{host}:{port}'
256+
return f'{scheme}://{user}:{quote_plus(password)}@{host}:{port}'
256257
logger.debug('Connecting to Elasticsearch without authentication.')
257258
return f'{scheme}://{host}:{port}'
258259

@@ -272,7 +273,7 @@ def get_postgres_url(
272273
password = password or PG_PASSWORD
273274
port = port or PG_PORT
274275
if password:
275-
return f'postgresql://{user}:{password}@{host}:{port}/{database}'
276+
return f'postgresql://{user}:{quote_plus(password)}@{host}:{port}/{database}'
276277
logger.debug('Connecting to Postgres without password.')
277278
return f'postgresql://{user}@{host}:{port}/{database}'
278279

@@ -286,7 +287,7 @@ def get_redis_url(host=None, password=None, port=None, db=None):
286287
port = port or REDIS_PORT
287288
db = db or REDIS_DB
288289
if password:
289-
return f'redis://:{password}@{host}:{port}/{db}'
290+
return f'redis://:{quote_plus(password)}@{host}:{port}/{db}'
290291
logger.debug('Connecting to Redis without password.')
291292
return f'redis://{host}:{port}/{db}'
292293

0 commit comments

Comments
 (0)