diff --git a/swh/loader/svn/svn.py b/swh/loader/svn/svn.py --- a/swh/loader/svn/svn.py +++ b/swh/loader/svn/svn.py @@ -13,7 +13,7 @@ import shutil import tempfile from typing import Dict, Iterator, List, Optional, Tuple, Union -from urllib.parse import urlparse, urlunparse +from urllib.parse import quote, urlparse, urlunparse from subvertpy import SubversionException, client, properties, wc from subvertpy.ra import ( @@ -43,7 +43,7 @@ def quote_svn_url(url: str) -> str: - return url.replace(" ", "%20").replace("#", "%23") + return quote(url, safe="/:!$&'()*+,=@") class SvnRepo: diff --git a/swh/loader/svn/tests/test_loader.py b/swh/loader/svn/tests/test_loader.py --- a/swh/loader/svn/tests/test_loader.py +++ b/swh/loader/svn/tests/test_loader.py @@ -3,6 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import itertools import logging import os import shutil @@ -2175,15 +2176,18 @@ check_snapshot(loader.snapshot, loader.storage) -@pytest.mark.parametrize( - "filename", ["file with spaces.txt", "file#with#hash#signs.txt"] -) -def test_loader_with_special_chars_in_svn_url(repo_url, tmp_path, filename): +def test_loader_with_special_chars_in_svn_url(repo_url, tmp_path): content = b"foo" + filename = "".join( + itertools.chain( + (chr(i) for i in range(32, 127)), (chr(i) for i in range(161, 256)) + ) + ) + add_commit( repo_url, - "Add file with spaces in its name", + "Add file with characters to quote in its name", [ CommitChange( change_type=CommitChangeType.AddOrUpdate,