Skip to content

Commit 6da61b6

Browse files
author
Ivana Atanasova
committed
Remove URL normalisation
As a target path is a URL path it's not correct to consider it as interchangeable with a filepath within every operation system. The unquote is also removed as the ngclient cannot assume correctly which encoding is intended and which not Fixes #1483 Signed-off-by: Ivana Atanasova <iyovcheva@iyovcheva-a02.vmware.com>
1 parent 1b5df4c commit 6da61b6

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

tests/test_fetcher_ng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def setUp(self):
5454
self.file_contents = target_fileobj.read()
5555
self.file_length = len(self.file_contents)
5656

57-
self.rel_target_filepath = os.path.basename(target_filepath)
57+
self.rel_target_filepath = os.path.basename(target_filepath).replace("\\","/")
5858
self.url_prefix = (
5959
f"http://{utils.TEST_HOST_ADDRESS}:"
6060
f"{str(self.server_process_handler.port)}"

tuf/ngclient/fetcher.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import tempfile
1111
from contextlib import contextmanager
1212
from typing import IO, Iterator
13-
from urllib import parse
1413

1514
from tuf import exceptions
1615

@@ -61,13 +60,6 @@ def download_file(self, url: str, max_length: int) -> Iterator[IO]:
6160
Yields:
6261
A TemporaryFile object that points to the contents of 'url'.
6362
"""
64-
# 'url.replace('\\', '/')' is needed for compatibility with
65-
# Windows-based systems, because they might use back-slashes in place
66-
# of forward-slashes. This converts it to the common format.
67-
# unquote() replaces %xx escapes in a url with their single-character
68-
# equivalent. A back-slash may beencoded as %5c in the url, which
69-
# should also be replaced with a forward slash.
70-
url = parse.unquote(url).replace("\\", "/")
7163
logger.debug("Downloading: %s", url)
7264

7365
number_of_bytes_received = 0

0 commit comments

Comments
 (0)