mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Quote URL before urlretrieve
This avoids unicode errors with URLs conaining non-ascii characters
This commit is contained in:
parent
515f2fb5b2
commit
00c455a748
1 changed files with 3 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue