Skip to content

Commit

Permalink
encode connection URL #65
Browse files Browse the repository at this point in the history
  • Loading branch information
toluaina committed Jan 26, 2021
1 parent 5925e25 commit 1f80e14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pgsync/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import threading
import time
from datetime import timedelta
from urllib.parse import quote_plus

from six import string_types

Expand Down Expand Up @@ -252,7 +253,7 @@ def get_elasticsearch_url(
user = user or ELASTICSEARCH_USER
password = password or ELASTICSEARCH_PASSWORD
if user:
return f'{scheme}://{user}:{password}@{host}:{port}'
return f'{scheme}://{user}:{quote_plus(password)}@{host}:{port}'
logger.debug('Connecting to Elasticsearch without authentication.')
return f'{scheme}://{host}:{port}'

Expand All @@ -272,7 +273,7 @@ def get_postgres_url(
password = password or PG_PASSWORD
port = port or PG_PORT
if password:
return f'postgresql://{user}:{password}@{host}:{port}/{database}'
return f'postgresql://{user}:{quote_plus(password)}@{host}:{port}/{database}'
logger.debug('Connecting to Postgres without password.')
return f'postgresql://{user}@{host}:{port}/{database}'

Expand All @@ -286,7 +287,7 @@ def get_redis_url(host=None, password=None, port=None, db=None):
port = port or REDIS_PORT
db = db or REDIS_DB
if password:
return f'redis://:{password}@{host}:{port}/{db}'
return f'redis://:{quote_plus(password)}@{host}:{port}/{db}'
logger.debug('Connecting to Redis without password.')
return f'redis://{host}:{port}/{db}'

Expand Down

0 comments on commit 1f80e14

Please sign in to comment.