From ff120795fbdeec0ffdb35334b6c09bcc1dc3d9a5 Mon Sep 17 00:00:00 2001 From: Vladimir Diaz Date: Fri, 25 May 2018 10:54:53 -0400 Subject: [PATCH] Replace %xx escapes in urls Signed-off-by: Vladimir Diaz --- tuf/download.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tuf/download.py b/tuf/download.py index 186360c4..9562f6ad 100755 --- a/tuf/download.py +++ b/tuf/download.py @@ -244,10 +244,12 @@ def _download_file(url, required_length, STRICT_REQUIRED_LENGTH=True): securesystemslib.formats.URL_SCHEMA.check_match(url) securesystemslib.formats.LENGTH_SCHEMA.check_match(required_length) - # 'url.replace()' is for compatibility with Windows-based systems because - # they might put back-slashes in place of forward-slashes. This converts it - # to the common format. - url = url.replace('\\', '/') + # 'url.replace('\\', '/')' is needed for compatibility with Windows-based + # systems, because they might use back-slashes in place of forward-slashes. + # This converts it to the common format. unquote() replaces %xx escapes in a + # url with their single-character equivalent. A back-slash may be encoded as + # %5c in the url, which should also be replaced with a forward slash. + url = six.moves.urllib.parse.unquote(url).replace('\\', '/') logger.info('Downloading: ' + repr(url)) # This is the temporary file that we will return to contain the contents of