Skip to content

Commit 3407881

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 <[email protected]>
1 parent 1b5df4c commit 3407881

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
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)}"

tests/test_updater_ng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def setUp(self):
109109
+ utils.TEST_HOST_ADDRESS
110110
+ ":"
111111
+ str(self.server_process_handler.port)
112-
+ repository_basepath
112+
+ repository_basepath.replace("\\","/")
113113
)
114114

115115
self.metadata_url = f"{url_prefix}/metadata/"

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)