diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index 204ab7b0..a36e89d5 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -13,7 +13,7 @@ import time from codecs import open from six.moves.urllib.error import URLError -from six.moves.urllib.parse import urlparse +from six.moves.urllib.parse import quote, urlparse from six.moves.urllib.request import urlretrieve # because logging.setLoggerClass has to be called before logging.getLogger @@ -667,7 +667,8 @@ def download_attachments(output_path, urls): os.makedirs(full_path) print('downloading {}'.format(filename)) try: - urlretrieve(url, os.path.join(full_path, filename)) + quote_url = quote(url, safe="%/:=&?~#+!$,;'@()*[]") + urlretrieve(quote_url, os.path.join(full_path, filename)) locations.append(os.path.join(localpath, filename)) except (URLError, IOError) as e: # Python 2.7 throws an IOError rather Than URLError