Skip to content

Commit 633a62e

Browse files
sfc-gh-stakedasfc-gh-abhatnagar
authored andcommitted
SNOW-132980 quote link parameters correctly
1 parent cbb0909 commit 633a62e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/test_unit_url.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def test_url():
1515
assert URL(account='testaccount', user='admin',
1616
password='test') == "snowflake://admin:test@testaccount/"
1717

18+
assert URL(account='testaccount', user='admin',
19+
password='1-pass 2-pass 3-: 4-@ 5-/ 6-pass') == \
20+
"snowflake://admin:1-pass 2-pass 3-%3A 4-%40 5-%2F 6-pass@testaccount/"
21+
1822
assert URL(account='testaccount', user='admin',
1923
password='test', database='testdb') == \
2024
"snowflake://admin:test@testaccount/testdb"

util.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from urllib.parse import quote_plus
1212

13+
from sqlalchemy.engine.url import _rfc_1738_quote
14+
1315

1416
def _url(**db_parameters):
1517
"""
@@ -23,7 +25,7 @@ def _url(**db_parameters):
2325
if 'host' in db_parameters:
2426
ret = 'snowflake://{user}:{password}@{host}:{port}/'.format(
2527
user=db_parameters.get('user', ''),
26-
password=quote_plus(db_parameters.get('password', '')),
28+
password=_rfc_1738_quote(db_parameters.get('password', '')),
2729
host=db_parameters['host'],
2830
port=db_parameters['port'] if 'port' in db_parameters else 443,
2931
)
@@ -32,14 +34,14 @@ def _url(**db_parameters):
3234
ret = 'snowflake://{user}:{password}@{account}/'.format(
3335
account=db_parameters['account'],
3436
user=db_parameters.get('user', ''),
35-
password=quote_plus(db_parameters.get('password', '')),
37+
password=_rfc_1738_quote(db_parameters.get('password', '')),
3638
)
3739
specified_parameters += ['user', 'password', 'account']
3840
else:
3941
ret = 'snowflake://{user}:{password}@{account}.{region}/'.format(
4042
account=db_parameters['account'],
4143
user=db_parameters.get('user', ''),
42-
password=quote_plus(db_parameters.get('password', '')),
44+
password=_rfc_1738_quote(db_parameters.get('password', '')),
4345
region=db_parameters['region'],
4446
)
4547
specified_parameters += ['user', 'password', 'account', 'region']

0 commit comments

Comments
 (0)