File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from vdirsyncer .storage .dav import _BAD_XML_CHARS
4
4
from vdirsyncer .storage .dav import _merge_xml
5
+ from vdirsyncer .storage .dav import _normalize_href
5
6
from vdirsyncer .storage .dav import _parse_xml
6
7
7
8
@@ -44,3 +45,13 @@ def test_xml_specialchars(char):
44
45
45
46
if char in _BAD_XML_CHARS :
46
47
assert x .text == "yes\n hello"
48
+
49
+
50
+ @pytest .mark .parametrize (
51
+ "href" ,
52
+ [
53
+ "/dav/calendars/user/testuser/123/UID%253A20210609T084907Z-@synaps-web-54fddfdf7-7kcfm%250A.ics" , # noqa: E501
54
+ ],
55
+ )
56
+ def test_normalize_href (href ):
57
+ assert href == _normalize_href ("https://example.com" , href )
Original file line number Diff line number Diff line change @@ -65,26 +65,18 @@ async def _assert_multistatus_success(r):
65
65
66
66
67
67
def _normalize_href (base , href ):
68
- """Normalize the href to be a path only relative to hostname and
69
- schema."""
68
+ """Normalize the href to be a path only relative to hostname and schema."""
70
69
orig_href = href
71
70
if not href :
72
71
raise ValueError (href )
73
72
74
73
x = urlparse .urljoin (base , href )
75
74
x = urlparse .urlsplit (x ).path
76
75
77
- # Encoding issues:
78
- # - https://github.com/owncloud/contacts/issues/581
79
- # - https://github.com/Kozea/Radicale/issues/298
80
- old_x = None
81
- while old_x is None or x != old_x :
82
- if _contains_quoted_reserved_chars (x ):
83
- break
84
- old_x = x
85
- x = urlparse .unquote (x )
86
-
87
- x = urlparse .quote (x , "/@%:" )
76
+ # We unquote and quote again, but want to make sure we
77
+ # keep around the "@" character.
78
+ x = urlparse .unquote (x )
79
+ x = urlparse .quote (x , "/@" )
88
80
89
81
if orig_href == x :
90
82
dav_logger .debug (f"Already normalized: { x !r} " )
You can’t perform that action at this time.
0 commit comments