Skip to content

Commit 8c34103

Browse files
authored
Less error logging
fix for #209 GMX server was sending some extra parameters in the XML. Those parameters are actually included in example code in the RFC, so we should accept it silently. #508
1 parent 949df4f commit 8c34103

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

caldav/davclient.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __init__(
101101
self, response: Response, davclient: Optional["DAVClient"] = None
102102
) -> None:
103103
self.headers = response.headers
104+
self.status = response.status_code
104105
log.debug("response headers: " + str(self.headers))
105106
log.debug("response status: " + str(self.status))
106107

@@ -114,7 +115,12 @@ def __init__(
114115
no_xml = ["text/plain", "text/calendar", "application/octet-stream"]
115116
expect_xml = any((content_type.startswith(x) for x in xml))
116117
expect_no_xml = any((content_type.startswith(x) for x in no_xml))
117-
if content_type and not expect_xml and not expect_no_xml:
118+
if (
119+
content_type
120+
and not expect_xml
121+
and not expect_no_xml
122+
and response.status_code < 400
123+
):
118124
error.weirdness(f"Unexpected content type: {content_type}")
119125
try:
120126
content_length = int(self.headers["Content-Length"])
@@ -350,11 +356,17 @@ def _expand_simple_prop(
350356
values = []
351357
if proptag in props_found:
352358
prop_xml = props_found[proptag]
353-
if prop_xml.items():
354-
from caldav.lib.debug import xmlstring
355-
359+
for item in prop_xml.items():
360+
if proptag == "{urn:ietf:params:xml:ns:caldav}calendar-data":
361+
if (
362+
item[0].lower().endswith("content-type")
363+
and item[1].lower() == "text/calendar"
364+
):
365+
continue
366+
if item[0].lower().endswith("version") and item[1] in ("2", "2.0"):
367+
continue
356368
log.error(
357-
f"If you see this, please add a report at https://github.com/python-caldav/caldav/issues/209 - in _expand_simple_prop, dealing with {proptag}, extra items found: {xmlstring(prop_xml)}."
369+
f"If you see this, please add a report at https://github.com/python-caldav/caldav/issues/209 - in _expand_simple_prop, dealing with {proptag}, extra item found: {'='.join(item)}."
358370
)
359371
if not xpath and len(prop_xml) == 0:
360372
if prop_xml.text:

0 commit comments

Comments
 (0)