Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions caldav/davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(
self, response: Response, davclient: Optional["DAVClient"] = None
) -> None:
self.headers = response.headers
self.status = response.status_code
log.debug("response headers: " + str(self.headers))
log.debug("response status: " + str(self.status))

Expand All @@ -114,7 +115,12 @@ def __init__(
no_xml = ["text/plain", "text/calendar", "application/octet-stream"]
expect_xml = any((content_type.startswith(x) for x in xml))
expect_no_xml = any((content_type.startswith(x) for x in no_xml))
if content_type and not expect_xml and not expect_no_xml:
if (
content_type
and not expect_xml
and not expect_no_xml
and response.status_code < 400
):
error.weirdness(f"Unexpected content type: {content_type}")
try:
content_length = int(self.headers["Content-Length"])
Expand Down Expand Up @@ -350,11 +356,17 @@ def _expand_simple_prop(
values = []
if proptag in props_found:
prop_xml = props_found[proptag]
if prop_xml.items():
from caldav.lib.debug import xmlstring

for item in prop_xml.items():
if proptag == "{urn:ietf:params:xml:ns:caldav}calendar-data":
if (
item[0].lower().endswith("content-type")
and item[1].lower() == "text/calendar"
):
continue
if item[0].lower().endswith("version") and item[1] in ("2", "2.0"):
continue
log.error(
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)}."
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)}."
)
if not xpath and len(prop_xml) == 0:
if prop_xml.text:
Expand Down