From 4b3f96db12a329c389051608af9e880a32622161 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Fri, 26 Sep 2014 20:10:41 +0200 Subject: [PATCH] Deal with case-insensitive servers See Davmail/Outlook, #113 --- vdirsyncer/storage/dav.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 8bc70b314..a664d903e 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -246,7 +246,7 @@ class DavStorage(Storage): def __init__(self, url, username='', password='', verify=True, auth=None, useragent=USERAGENT, unsafe_href_chars='@', - verify_fingerprint=None, **kwargs): + verify_fingerprint=None, case_sensitive=True, **kwargs): super(DavStorage, self).__init__(**kwargs) url = url.rstrip('/') + '/' @@ -256,6 +256,7 @@ def __init__(self, url, username='', password='', verify=True, auth=None, self.session = DavSession(url, username, password, verify, auth, useragent, verify_fingerprint) self.unsafe_href_chars = unsafe_href_chars + self.case_sensitive = case_sensitive # defined for _repr_attributes self.username = username @@ -276,8 +277,10 @@ def discover(cls, url, **kwargs): s.displayname = c['displayname'] yield s - def _normalize_href(self, *args, **kwargs): - return _normalize_href(self.session.url, *args, **kwargs) + def _normalize_href(self, href, *args, **kwargs): + if not self.case_sensitive: + href = href.lower() + return _normalize_href(self.session.url, href, *args, **kwargs) def _get_href(self, item): href = item.ident