Skip to content

Commit

Permalink
URL unquote escaped credentials in feed URL
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed Jan 12, 2017
1 parent 1a621e6 commit dd4e491
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions server/pulp/server/controllers/importer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import sys
import urllib
import urlparse

import celery
Expand Down Expand Up @@ -54,8 +55,10 @@ def clean_config_dict(config):
parsed = urlparse.urlparse(feed_url)
if parsed.username or parsed.password:
new_url = parsed._replace(netloc=parsed.netloc.rsplit('@', 1)[1])
config[importer_constants.KEY_BASIC_AUTH_USER] = parsed.username
config[importer_constants.KEY_BASIC_AUTH_PASS] = parsed.password
if parsed.username is not None:
config[importer_constants.KEY_BASIC_AUTH_USER] = urllib.unquote(parsed.username)
if parsed.password is not None:
config[importer_constants.KEY_BASIC_AUTH_PASS] = urllib.unquote(parsed.password)
config['feed'] = new_url.geturl()

return dict([(k, v) for k, v in config.items() if v is not None])
Expand Down
2 changes: 1 addition & 1 deletion server/test/unit/server/controllers/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_feed_with_basic_auth_username_password_at_symbol(self):
"""
Ensure that usernames and passwords can contain the '@' symbol.
"""
mock_config = {'feed': 'http://mock@user:mock@pass@realfeed.com'}
mock_config = {'feed': 'http://mock%40user:mock%40pass@realfeed.com'}
expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': 'mock@user',
'basic_auth_password': 'mock@pass'}
result = importer.clean_config_dict(mock_config)
Expand Down

0 comments on commit dd4e491

Please sign in to comment.