carddav-util icon indicating copy to clipboard operation
carddav-util copied to clipboard

fix compatibility with sogo

Open LU-386 opened this issue 3 years ago • 2 comments
trafficstars

Hey Lukasz,

I had a problem with compatibility with sogo. To fix the issue, just remove the following lines below from carddav.py. I could not find a problem with this fix so far or any advantage of those lines so far (compatibility with baikal and sogo tested).

if response.headers['DAV'].count('addressbook') == 0:
    raise Exception("URL is not a CardDAV resource")

LU-386 avatar Sep 22 '22 22:09 LU-386

Thanks for the report!

This seems like a useful check though. Can you submit the PR where this check is omitted for sogo? The server software name is usually somewhere in the response headers.

ljanyst avatar Sep 23 '22 06:09 ljanyst

You're welcome!

I don't know which variable to use, the one the condition is asking for is not present. Below is an object-dump created with the following lines in carddav.py:

264         raise_for_status( response )
265        
266         for attr in dir(response.headers):
267             print("obj.%s = %r" % (attr, getattr(response.headers, attr)))
obj._MutableMapping__marker = <object object at 0x7f66cfddc180>
obj.__abstractmethods__ = frozenset()
obj.__class__ = <class 'requests.structures.CaseInsensitiveDict'>
obj.__class_getitem__ = <bound method GenericAlias of <class 'requests.structures.CaseInsensitiveDict'>>
obj.__contains__ = <bound method Mapping.__contains__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__delattr__ = <method-wrapper '__delattr__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__delitem__ = <bound method CaseInsensitiveDict.__delitem__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__dict__ = {'_store': OrderedDict([('server', ('Server', 'nginx')), ('date', ('Date', 'Sun, 25 Sep 2022 08:01:05 GMT')), ('content-type', ('Content-Type', 'text/xml; charset=utf-8')), ('content-length', ('Content-Length', '111062')), ('connection', ('Connection', 'keep-alive')), ('x-dav-error', ('X-Dav-Error', '200 No error')), ('ms-author-via', ('Ms-Author-Via', 'DAV')), ('pragma', ('Pragma', 'no-cache')), ('content-encoding', ('Content-Encoding', 'gzip')), ('cache-control', ('Cache-Control', 'no-cache')), ('x-frame-options', ('X-Frame-Options', 'SAMEORIGIN'))])}
obj.__dir__ = <built-in method __dir__ of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__doc__ = "A case-insensitive ``dict``-like object.\n\n    Implements all methods and operations of\n    ``MutableMapping`` as well as dict's ``copy``. Also\n    provides ``lower_items``.\n\n    All keys are expected to be strings. The structure remembers the\n    case of the last key to be set, and ``iter(instance)``,\n    ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``\n    will contain case-sensitive keys. However, querying and contains\n    testing is case insensitive::\n\n        cid = CaseInsensitiveDict()\n        cid['Accept'] = 'application/json'\n        cid['aCCEPT'] == 'application/json'  # True\n        list(cid) == ['Accept']  # True\n\n    For example, ``headers['content-encoding']`` will return the\n    value of a ``'Content-Encoding'`` response header, regardless\n    of how the header name was originally stored.\n\n    If the constructor, ``.update``, or equality comparison\n    operations are given keys that have equal ``.lower()``s, the\n    behavior is undefined.\n    "
obj.__eq__ = <bound method CaseInsensitiveDict.__eq__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__format__ = <built-in method __format__ of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__ge__ = <method-wrapper '__ge__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__getattribute__ = <method-wrapper '__getattribute__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__getitem__ = <bound method CaseInsensitiveDict.__getitem__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__gt__ = <method-wrapper '__gt__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__hash__ = None
obj.__init__ = <bound method CaseInsensitiveDict.__init__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__init_subclass__ = <built-in method __init_subclass__ of ABCMeta object at 0x5634b8d84c70>
obj.__iter__ = <bound method CaseInsensitiveDict.__iter__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__le__ = <method-wrapper '__le__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__len__ = <bound method CaseInsensitiveDict.__len__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__lt__ = <method-wrapper '__lt__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__module__ = 'requests.structures'
obj.__ne__ = <method-wrapper '__ne__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__new__ = <built-in method __new__ of type object at 0x7f66d0596d60>
obj.__reduce__ = <built-in method __reduce__ of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__reduce_ex__ = <built-in method __reduce_ex__ of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__repr__ = <bound method CaseInsensitiveDict.__repr__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__reversed__ = None
obj.__setattr__ = <method-wrapper '__setattr__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__setitem__ = <bound method CaseInsensitiveDict.__setitem__ of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.__sizeof__ = <built-in method __sizeof__ of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__slots__ = ()
obj.__str__ = <method-wrapper '__str__' of CaseInsensitiveDict object at 0x7f66ce4ab160>
obj.__subclasshook__ = <bound method Collection.__subclasshook__ of <class 'requests.structures.CaseInsensitiveDict'>>
obj.__weakref__ = None
obj._abc_impl = <_abc._abc_data object at 0x7f66ceff5c40>
obj._store = OrderedDict([('server', ('Server', 'nginx')), ('date', ('Date', 'Sun, 25 Sep 2022 08:01:05 GMT')), ('content-type', ('Content-Type', 'text/xml; charset=utf-8')), ('content-length', ('Content-Length', '111062')), ('connection', ('Connection', 'keep-alive')), ('x-dav-error', ('X-Dav-Error', '200 No error')), ('ms-author-via', ('Ms-Author-Via', 'DAV')), ('pragma', ('Pragma', 'no-cache')), ('content-encoding', ('Content-Encoding', 'gzip')), ('cache-control', ('Cache-Control', 'no-cache')), ('x-frame-options', ('X-Frame-Options', 'SAMEORIGIN'))])
obj.clear = <bound method MutableMapping.clear of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.copy = <bound method CaseInsensitiveDict.copy of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.get = <bound method Mapping.get of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.items = <bound method Mapping.items of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.keys = <bound method Mapping.keys of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.lower_items = <bound method CaseInsensitiveDict.lower_items of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.pop = <bound method MutableMapping.pop of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.popitem = <bound method MutableMapping.popitem of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.setdefault = <bound method MutableMapping.setdefault of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.update = <bound method MutableMapping.update of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>
obj.values = <bound method Mapping.values of {'Server': 'nginx', 'Date': 'Sun, 25 Sep 2022 08:01:05 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '111062', 'Connection': 'keep-alive', 'X-Dav-Error': '200 No error', 'Ms-Author-Via': 'DAV', 'Pragma': 'no-cache', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'X-Frame-Options': 'SAMEORIGIN'}>

Could you maybe provide a header dump from another system to look for similarities? (btw your script works great!)

LU-386 avatar Sep 25 '22 08:09 LU-386