Skip to content

Commit 1e88f88

Browse files
authored
Strip the DTSTAMP value from ical before comparing them (#520)
Fixes #380 #520
1 parent d60c0f9 commit 1e88f88

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

caldav/davclient.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,22 @@ def principals(self, name=None):
563563
## TODO: allow server side filtering. We need a <D:property-search><D:prop><D:displayname/></D:prop><D:match>{name}</D:match></D:property-search> inside the PrincipalPropertySearch
564564

565565
if name:
566-
name_filter = [ dav.PropertySearch() + [dav.Prop() + [dav.DisplayName()]] + dav.Match(value=name)]
567-
import pdb; pdb.set_trace()
566+
name_filter = [
567+
dav.PropertySearch()
568+
+ [dav.Prop() + [dav.DisplayName()]]
569+
+ dav.Match(value=name)
570+
]
571+
import pdb
572+
573+
pdb.set_trace()
568574
else:
569575
name_filter = []
570576

571-
query = dav.PrincipalPropertySearch() + name_filter + [
572-
dav.Prop() + cdav.CalendarHomeSet() + dav.DisplayName()
573-
]
577+
query = (
578+
dav.PrincipalPropertySearch()
579+
+ name_filter
580+
+ [dav.Prop() + cdav.CalendarHomeSet() + dav.DisplayName()]
581+
)
574582
response = self.report(self.url, etree.tostring(query.xmlelement()))
575583
principal_dict = response.find_objects_and_props()
576584
ret = []

caldav/elements/dav.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ class PrincipalPropertySearch(BaseElement):
3030
class PropertySearch(BaseElement):
3131
tag: ClassVar[str] = ns("D", "property-search")
3232

33+
3334
# Filters
3435

36+
3537
class Match(BaseElement):
3638
tag: ClassVar[str] = ns("D", "match")
3739

40+
3841
# Conditions
3942
class SyncToken(BaseElement):
4043
tag: ClassVar[str] = ns("D", "sync-token")

tests/test_vcal.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ def assertSameICal(self, ical1, ical2, ignore_uid=False):
4040
"""helper method"""
4141

4242
def normalize(s, ignore_uid):
43+
## TODO: This may break in case of line wrappings
44+
## We're explicitly not using any libraries for this, as it may skew the test
4345
s = to_wire(s).replace(b"\r\n", b"\n").strip().split(b"\n")
4446
s.sort()
4547
if ignore_uid:
4648
s = [x for x in s if not x.startswith(b"UID:")]
49+
## ref https://github.com/python-caldav/caldav/issues/380
50+
for i in range(0, len(s)):
51+
## We cut the value itself, just asserting the attribute is present
52+
if s[i].startswith(b"DTSTAMP"):
53+
s[i] = s[i][:9]
4754
return b"\n".join(s)
4855

4956
self.assertEqual(normalize(ical1, ignore_uid), normalize(ical2, ignore_uid))

0 commit comments

Comments
 (0)