Skip to content

Commit 889183e

Browse files
author
Hugo Osvaldo Barrera
committed
I think this makes sense
1 parent 0650cc3 commit 889183e

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

tests/storage/dav/test_main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from vdirsyncer.storage.dav import _BAD_XML_CHARS
44
from vdirsyncer.storage.dav import _merge_xml
5+
from vdirsyncer.storage.dav import _normalize_href
56
from vdirsyncer.storage.dav import _parse_xml
67

78

@@ -44,3 +45,13 @@ def test_xml_specialchars(char):
4445

4546
if char in _BAD_XML_CHARS:
4647
assert x.text == "yes\nhello"
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)

vdirsyncer/storage/dav.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,18 @@ async def _assert_multistatus_success(r):
6565

6666

6767
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."""
7069
orig_href = href
7170
if not href:
7271
raise ValueError(href)
7372

7473
x = urlparse.urljoin(base, href)
7574
x = urlparse.urlsplit(x).path
7675

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, "/@")
8880

8981
if orig_href == x:
9082
dav_logger.debug(f"Already normalized: {x!r}")

0 commit comments

Comments
 (0)