From de11ec10864a1f9abd6693b49a48350a1ad488fc Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Sun, 1 Nov 2026 13:22:55 +0100 Subject: [PATCH 1/3] fix: refuse a stale ETag a server's DELETE ignores SOGo, Zimbra, Bedework and Posteo delete an object on a stale If-Match (delete.if-match broken), so delete(if_match=...) deleted a version someone else had saved since. There it now reads the ETag with a PROPFIND first and raises ETagMismatchError on a changed object, as save() stands in for the wildcard preconditions a server gets wrong. A window remains between the read and the DELETE. Prompt: (In the calendaring client library) Please continue work on getting the conformance tests passing. (earlier prompt: It's better to fix things properly than to make workarounds. It's within the scope to do changes in [the caldav and caldav-server-tester checkouts] if needed) Followup-Prompt: You can let the old uncommitted changes piggy-back into the same commit. Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/calendarobjectresource.py | 58 +++++++++++ caldav/compatibility_hints.py | 4 +- changes/+delete-if-match-ignored.fixed.md | 1 + tests/test_caldav_unit.py | 118 ++++++++++++++++++++++ 4 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 changes/+delete-if-match-ignored.fixed.md diff --git a/caldav/calendarobjectresource.py b/caldav/calendarobjectresource.py index d2bd84f1..da77a7c2 100644 --- a/caldav/calendarobjectresource.py +++ b/caldav/calendarobjectresource.py @@ -1342,6 +1342,13 @@ def delete( ``if_match=True`` with neither tag cached, or an empty string, raises ``ValueError`` rather than deleting unconditionally; so does a cached ETag that is weak, as it can never match. + Where the server deletes on a stale ``If-Match`` anyway + (``delete.if-match`` broken), the ETag is read first and a + changed object refused with ``ETagMismatchError`` before the + DELETE; that leaves a window between the two requests. If that + read fails, nothing is deleted; if it gives no ETag, the DELETE + goes ahead unchecked. A Schedule-Tag precondition is sent as it + is, with no read first. ``precondition`` works as in ``save()``: ``"etag"`` makes ``if_match=True`` prefer ``If-Match`` over a cached Schedule-Tag. @@ -1371,8 +1378,59 @@ def delete( ) else: headers = {"if-match": if_match} + if self._ignores_delete_if_match(headers): + if self.is_async_client: + return self._async_delete_unless_changed(headers) + cached = self.etag + try: + current = self.get_property(dav.GetEtag()) + finally: + self._restore_etag(cached) + self._refuse_changed(current, headers["if-match"]) return self._delete(headers) + def _ignores_delete_if_match(self, headers: dict[str, str]) -> bool: + """Does the server delete on a stale If-Match (``delete.if-match`` broken)? + + Then the ETag is read first, and a stale one refused here: a + window between the read and the DELETE, where the server's own + check has none. ``*`` needs no check, a DELETE of a missing + object fails anyway (``delete.missing``). + """ + etag = headers.get("if-match") + if etag is None or etag == "*": + return False + features = self.client.features if self.client is not None else None + return features is not None and features.is_supported("delete.if-match", str) == "broken" + + async def _async_delete_unless_changed(self, headers: dict[str, str]) -> None: + cached = self.etag + try: + current = await self.get_property(dav.GetEtag()) + finally: + self._restore_etag(cached) + self._refuse_changed(current, headers["if-match"]) + await self._delete(headers) + + def _restore_etag(self, cached: str | None) -> None: + """Put back the ETag the object was read with: the check reads the + server's into ``props``, and a refused delete must not leave a newer + ETag behind for a retry, or a save(), to pass on.""" + if cached is None: + self.props.pop(dav.GetEtag.tag, None) + else: + self.props[dav.GetEtag.tag] = cached + + def _refuse_changed(self, current: str | None, expected: str) -> None: + """ETagMismatchError unless ``current`` is ``expected``, compared weakly + (RFC 9110 section 8.8.3.2): the opaque tag is what tells a version. + No ``current`` passes: the server gave nothing to compare.""" + if current is not None and current.removeprefix("W/") != expected.removeprefix("W/"): + raise error.ETagMismatchError( + str(self.url), + f"the object has ETag {current}, not {expected}: it changed since it was read", + ) + def cancel(self, **kwargs: Any) -> "Self | Coroutine[Any, Any, Self]": """Mark the object as cancelled (``STATUS:CANCELLED``) and save it. diff --git a/caldav/compatibility_hints.py b/caldav/compatibility_hints.py index 91229297..0851e157 100644 --- a/caldav/compatibility_hints.py +++ b/caldav/compatibility_hints.py @@ -971,7 +971,7 @@ class FeatureSet: }, "delete": {"description": "Deleting a calendar object resource. Deleting a whole calendar is delete-calendar."}, "delete.if-match": { - "description": "A DELETE carrying If-Match with an etag the object no longer has is refused with 412 Precondition Failed, and one carrying the current etag goes through. RFC 9110 section 13.1.1 says the server MUST NOT perform the method when the condition does not hold; delete(if_match=True) relies on it to avoid deleting a version someone else has saved since it was loaded. When 'broken', the condition is ignored and a stale If-Match deletes the object anyway (SOGo, while it honours a stale If-Match on PUT; Zimbra, Bedework 3 and 5, Posteo). When 'unsupported', a DELETE with the current etag is refused too. The default is 'full', as for save-load.mutable.if-match-wildcard: RFC 4791 section 2 requires ETag support as RFC 2616 defines it.", + "description": "A DELETE carrying If-Match with an etag the object no longer has is refused with 412 Precondition Failed, and one carrying the current etag goes through. RFC 9110 section 13.1.1 says the server MUST NOT perform the method when the condition does not hold; delete(if_match=True) relies on it to avoid deleting a version someone else has saved since it was loaded. When 'broken', the condition is ignored and a stale If-Match deletes the object anyway (SOGo, while it honours a stale If-Match on PUT; Zimbra, Bedework 3 and 5, Posteo); delete(if_match=...) then reads the ETag first and refuses a changed object itself, with a window between the read and the DELETE. When 'unsupported', a DELETE with the current etag is refused too. The default is 'full', as for save-load.mutable.if-match-wildcard: RFC 4791 section 2 requires ETag support as RFC 2616 defines it.", "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.1", "https://datatracker.ietf.org/doc/html/rfc4791#section-2"], }, @@ -984,7 +984,7 @@ class FeatureSet: "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc9110#section-13.2.1"], }, - "save.duplicate-uid": {}, + "save.duplicate-uid": {}, ## TODO: should consider reorganizing here. See also `no-uid-conflict`. "save.duplicate-uid.cross-calendar": { "description": "Server allows events with the same UID to exist in different calendars and treats them as separate entities. Support can be 'full' (allowed), 'ungraceful' (rejected with error), or 'unsupported' (silently ignored or moved). Behaviour 'silently-ignored' means the duplicate is not saved but no error is thrown. Behaviour 'moved-instead-of-copied' means the event is moved from the original calendar to the new calendar (Zimbra behavior)" }, diff --git a/changes/+delete-if-match-ignored.fixed.md b/changes/+delete-if-match-ignored.fixed.md new file mode 100644 index 00000000..3183086f --- /dev/null +++ b/changes/+delete-if-match-ignored.fixed.md @@ -0,0 +1 @@ +`delete(if_match=...)` deleted a changed object on servers that ignore `If-Match` on DELETE (SOGo, Zimbra, Bedework, Posteo: `delete.if-match` broken). There it now reads the ETag first and raises `ETagMismatchError` if the object changed; a window remains between the read and the DELETE. diff --git a/tests/test_caldav_unit.py b/tests/test_caldav_unit.py index 64bcec43..c72ed9c1 100755 --- a/tests/test_caldav_unit.py +++ b/tests/test_caldav_unit.py @@ -7303,6 +7303,124 @@ def test_unknown_precondition_is_refused(self, base, value) -> None: assert sent == [] +class TestDeleteIfMatchIgnored: + """Where ``delete.if-match`` is broken, the server deletes on a stale + If-Match (SOGo, Zimbra, Bedework, Posteo). delete(if_match=...) then + reads the current ETag first and refuses a stale one itself, as save() + stands in for the wildcard preconditions a server gets wrong.""" + + URL = "http://cal.example.com/dav/user/mycal/ev1.ics" + + @pytest.fixture(params=["sync", "async"]) + def base(self, request): + if request.param == "sync": + return DAVClient + from caldav.async_davclient import AsyncDAVClient + + return AsyncDAVClient + + @staticmethod + def _etag_multistatus(etag): + return ( + '\n' + "/dav/user/mycal/ev1.ics" + f"{etag}" + "HTTP/1.1 200 OK" + ).encode() + + def _event(self, base, stored_etag, support="broken", propfind_status=207): + sent = [] + features = {"delete.if-match": {"support": support}} + client = base(url="http://cal.example.com/dav/", features=features) + + def request(url, method="GET", body="", headers=None): + method = method.upper() + sent.append((method, {k.lower(): v for k, v in (headers or {}).items()})) + resp = mock.MagicMock() + resp.reason = "whatever" + if method == "PROPFIND": + resp.status_code = propfind_status + resp.content = ( + self._etag_multistatus(stored_etag) if propfind_status == 207 else b"" + ) + else: + resp.status_code = 204 + resp.content = b"" + resp.headers = {"Content-Type": "application/xml"} if resp.content else {} + resp.text = resp.content.decode() + return DAVResponse(resp, client) + + if base is DAVClient: + client.request = request + else: + + async def async_request(*args, **kwargs): + return request(*args, **kwargs) + + client.request = async_request + cal = Calendar(client, url="http://cal.example.com/dav/user/mycal/") + event = Event(client, url=self.URL, data=ev1, parent=cal) + event.props[dav.GetEtag.tag] = '"etag-a"' + return event, sent + + _run = staticmethod(TestConditionalWrite._run) + + def test_stale_etag_is_refused_before_the_delete(self, base) -> None: + event, sent = self._event(base, stored_etag='"etag-b"') + with pytest.raises(error.ETagMismatchError): + self._run(event, if_match=True) + assert [m for m, _ in sent] == ["PROPFIND"] + + def test_refusal_keeps_the_etag_the_object_was_read_with(self, base) -> None: + """The newer ETag from the check must not let a retry, or a save(), pass.""" + event, sent = self._event(base, stored_etag='"etag-b"') + with pytest.raises(error.ETagMismatchError): + self._run(event, if_match=True) + assert event.etag == '"etag-a"' + with pytest.raises(error.ETagMismatchError): + self._run(event, if_match=True) + assert [m for m, _ in sent] == ["PROPFIND", "PROPFIND"] + + def test_current_etag_deletes(self, base) -> None: + event, sent = self._event(base, stored_etag='"etag-a"') + self._run(event, if_match='"etag-a"') + assert [m for m, _ in sent] == ["PROPFIND", "DELETE"] + assert sent[-1][1]["if-match"] == '"etag-a"' + + def test_weak_form_of_the_same_etag_deletes(self, base) -> None: + event, sent = self._event(base, stored_etag='W/"etag-a"') + self._run(event, if_match=True) + assert [m for m, _ in sent] == ["PROPFIND", "DELETE"] + + def test_missing_object_raises_not_found(self, base) -> None: + event, sent = self._event(base, stored_etag=None, propfind_status=404) + with pytest.raises(error.NotFoundError): + self._run(event, if_match=True) + assert [m for m, _ in sent] == ["PROPFIND"] + + def test_wildcard_needs_no_check(self, base) -> None: + event, sent = self._event(base, stored_etag='"etag-b"') + self._run(event, if_match="*") + assert [m for m, _ in sent] == ["DELETE"] + + @pytest.mark.parametrize("support", ["full", "unsupported"]) + def test_server_honouring_if_match_is_not_asked_first(self, base, support) -> None: + """'unsupported' refuses the current etag too: a check first would not help.""" + event, sent = self._event(base, stored_etag='"etag-b"', support=support) + self._run(event, if_match=True) + assert [m for m, _ in sent] == ["DELETE"] + + @pytest.mark.parametrize( + "server", ["sogo", "zimbra_8_8", "bedework_3_10_3", "bedework_5_0_0", "posteo"] + ) + def test_hints_of_servers_ignoring_if_match_on_delete(self, server) -> None: + from caldav import compatibility_hints + from caldav.compatibility_hints import FeatureSet + + fs = FeatureSet(getattr(compatibility_hints, server)) + assert fs.is_supported("delete.if-match", str) == "broken" + + class TestDelayedPropertyWrite: """``synchronous-write.proppatch`` declared unsupported with a ``delay``: a PROPPATCH is answered at once but a PROPFIND keeps returning the old From 67d61e6e31d1e112e250096d00f78d9116695be2 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Sun, 1 Nov 2026 13:23:21 +0100 Subject: [PATCH 2/3] fix: an XML declaration alone is no content Zimbra answers a calendar-multiget naming an href without .ics with 200 and an XML declaration but no document. DAVResponse let lxml's XMLSyntaxError escape, so a lookup of a missing object crashed rather than finding nothing. Such a body now counts as no content, and a response without content has no multistatus responses. Prompt: (In the calendaring client library) Please continue work on getting the conformance tests passing. (earlier prompt: It's better to fix things properly than to make workarounds. It's within the scope to do changes in [the caldav and caldav-server-tester checkouts] if needed) Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/response.py | 17 ++++++++++++++++- changes/+xml-declaration-only.fixed.md | 1 + tests/test_async_davclient.py | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 changes/+xml-declaration-only.fixed.md diff --git a/caldav/response.py b/caldav/response.py index 678d17e7..e2135af2 100644 --- a/caldav/response.py +++ b/caldav/response.py @@ -94,6 +94,15 @@ def _normalize_href(text: str, preserve_at: bool = False) -> str: return decode(text) +def _only_xml_declaration(raw: bytes | str) -> bool: + """Is ``raw`` an XML declaration followed by nothing but whitespace?""" + if len(raw) > 256: # a declaration is short; spare a large body the decoding + return False + text = raw.decode("utf-8", "replace") if isinstance(raw, bytes) else raw + text = text.strip().lstrip("\ufeff") + return text.startswith("") and text.count("<") == 1 + + def _validate_status(status: str | None) -> None: """Validate a status string like "HTTP/1.1 404 Not Found". @@ -387,7 +396,9 @@ def _init_from_response(self, response: "Response", davclient: Any = None) -> No content_length = int(self.headers["Content-Length"]) except (KeyError, ValueError, TypeError): content_length = -1 - if content_length == 0 or not self._raw: + ## Zimbra answers some requests with an XML declaration and no + ## document; that is no content, not a malformed document + if content_length == 0 or not self._raw or _only_xml_declaration(self._raw): self._raw = "" self.tree = None log.debug("No content delivered") @@ -475,7 +486,11 @@ def _strip_to_multistatus(self) -> _Element | list[_Element]: (The equivalent of this method could probably be found with a simple XPath query, but I'm not much into XPath) + + A response without content has no responses. """ + if self.tree is None: + return [] return _strip_to_multistatus(self.tree) def validate_status(self, status: str) -> None: diff --git a/changes/+xml-declaration-only.fixed.md b/changes/+xml-declaration-only.fixed.md new file mode 100644 index 00000000..c1f70000 --- /dev/null +++ b/changes/+xml-declaration-only.fixed.md @@ -0,0 +1 @@ +A response holding only an XML declaration, as Zimbra gives to a calendar-multiget naming an href without `.ics`, raised lxml's `XMLSyntaxError`. It is now taken as a response without content. diff --git a/tests/test_async_davclient.py b/tests/test_async_davclient.py index 0e000f32..6a2cf99e 100644 --- a/tests/test_async_davclient.py +++ b/tests/test_async_davclient.py @@ -103,6 +103,22 @@ def test_response_with_empty_content(self) -> None: assert dav_response.tree is None assert dav_response._raw == "" + @pytest.mark.parametrize("bom", [b"", b"\xef\xbb\xbf"]) + def test_response_with_only_an_xml_declaration(self, bom: bytes) -> None: + """Zimbra answers a calendar-multiget naming an href without .ics + with 200 and an XML declaration but no document: no content.""" + resp = create_mock_response( + content=bom + b'\n\n', + status_code=200, + headers={"Content-Type": 'text/xml; charset="UTF-8"'}, + ) + + dav_response = DAVResponse(resp) + + assert dav_response.status == 200 + assert dav_response.tree is None + assert dav_response.expand_simple_props([]) == {} + def test_response_with_non_xml_content(self) -> None: """Test response with non-XML content.""" resp = create_mock_response( From 59a64fed49b83560401c1e198384973c10a4fc13 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 3 Nov 2026 18:08:00 +0100 Subject: [PATCH 3/3] feat: hints for task values, X- params, ghosts Probing Ox and Zimbra for the calendaring conformance suite found more data they lose than the profiles said. New hints record which task STATUS (RFC 5545's, and RFC 10051's in a child) and PRIORITY values a server keeps, maps or refuses; whether it advertises RFC 10051 (supported-task-modes); X- parameters dropped; multiget answering for deleted objects (Zimbra); and Ox naming only tasks .ics. Prompt: [fix the unmapped caldav hints, new caldav-server-tester checks and caldav profile updates now] Prompts (comments made inline in the document while reviewing it): > (on the save-load.todo.status hint) Note for "save-load.todo.status" - a server may or may not support RFC 10051. We can only demand it to support FAILED and PENDING if the server declares support for RFC 50051 (sic). If there are many servers acceptign (sic) all the RFC 5545 statuses but not accepting FAILED and PENDING, then maybe we need to split out a child for the RFC 10051-statuses Followup-Prompt: There exists a DAV-property in the RFC for querying for support as far as I remember. The probe for it should be added in the caldav-server-tester as for now. save-load.todo.status.rfc10051 is fine. (...) [the DAV property: CALDAV:supported-task-mode-set, RFC 10051 section 13.1] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/compatibility_hints.py | 70 +++++++++++++++++-- ...lues-x-parameter-multiget-deleted.added.md | 1 + tests/test_compatibility_hints.py | 36 ++++++++++ 3 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 changes/+todo-values-x-parameter-multiget-deleted.added.md diff --git a/caldav/compatibility_hints.py b/caldav/compatibility_hints.py index 0851e157..cbec87dc 100644 --- a/caldav/compatibility_hints.py +++ b/caldav/compatibility_hints.py @@ -251,6 +251,12 @@ class FeatureSet: ## default whatever they say. Do not hint it - the ancestor walk ## would hand the hint to both children. }, + "supported-task-modes": { + "description": "The server advertises the CALDAV:supported-task-mode-set property (RFC 10051 section 13.1) on the calendar home or a calendar, which is how it says it supports RFC 10051. Without it a client must assume the server does not. 'unsupported' when neither has it (Ox, Zimbra); the extra key values lists the TASK-MODE values advertised. 'unknown' by default: few servers advertise it, but one not probed is not known to lack it.", + "default": {"support": "unknown"}, + "extra_keys": {"values": "The TASK-MODE values the property lists."}, + "links": ["https://datatracker.ietf.org/doc/html/rfc10051#section-13.1"], + }, "supported-components.property-exists": { "description": "Server returns the supported-calendar-component-set property (RFC 4791 section 5.2.3) on a calendar. The property is optional: when absent the RFC mandates that all component types are accepted, so 'unsupported' here is not a protocol violation, but the client cannot determine the actual supported set without trying. Up to caldav 3.6.0 this was 'get-supported-components'.", "default": {"support": "full"}, @@ -417,6 +423,10 @@ class FeatureSet: "description": "A calendar-multiget naming an href that does not exist answers it with a 404 entry in the multistatus. RFC 4791 section 7.9 and the multistatus of RFC 4918 section 13 give every requested href a response. When 'unsupported', the href is left out (Baikal), so a client cannot tell a missing object from one the server forgot to answer for.", "default": {"support": "full"}, }, + "multiget.deleted": { + "description": "A calendar-multiget naming an object that was deleted answers it as missing, as a GET does. 'broken' when it still returns the object's data after the DELETE succeeded and a GET answers 404, so a client fetching by multiget sees deleted objects.", + "default": {"support": "full"}, + }, "multiget.limit": { "description": "A calendar-multiget answers every href it names, however many. When 'unsupported', the server answers at most a number of its own and a 507 for the collection, even when the request asked for no more (Stalwart, at its WebDav.maxResults setting, 2000 by default); a client should then fetch in batches. As for propfind.limit, the probe only sees a limit below CALDAV_SERVER_TESTER_LIMIT_OBJECTS.", "default": {"support": "full"}, @@ -470,6 +480,36 @@ class FeatureSet: "save-load.todo.mixed-calendar": {"description": "The same calendar may contain both events and tasks (Zimbra only allows tasks to be placed on special task lists)", "default": {"support": "full"}}, "save-load.todo.uncomplete": {"description": "A completed task can be made pending again (Todo.uncomplete()): after saving it with STATUS:NEEDS-ACTION and without COMPLETED, it loads back that way.", "default": {"support": "full"}}, "save-load.todo.attendee": {"description": "A task with an ATTENDEE (RFC 5545 section 3.6.2 allows it in a VTODO) is stored with it. The probe sends no ORGANIZER, so no scheduling applies. 'unsupported' when the ATTENDEE is dropped. 'broken' when the task with it is gone although the PUT succeeded: the PUT is answered with 201 and the GET with 404, while the same task without the ATTENDEE is kept. 'ungraceful' when it is refused (Ox, with 409).", "default": {"support": "full"}}, + "save-load.todo.status": { + "description": "Each STATUS RFC 5545 section 3.8.1.11 gives a task (NEEDS-ACTION, IN-PROCESS, COMPLETED, CANCELLED) is stored as sent. 'unsupported' when one is dropped or stored as another, 'ungraceful' when a task with one is refused, the worse of the two where both apply; the extra keys say which. Zimbra refuses CANCELLED. The statuses RFC 10051 adds are save-load.todo.status.rfc10051.", + "default": {"support": "full"}, + "extra_keys": { + "values": "The statuses stored as sent.", + "map": "A status, to the one stored instead.", + "refused": "The statuses a task is refused with.", + }, + "links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.1.11"], + }, + "save-load.todo.status.rfc10051": { + "description": "The statuses RFC 10051 adds for a task, PENDING and FAILED, are stored as sent. Graded and keyed as save-load.todo.status. A profile stating save-load.todo.status states this one too: without it, this feature would answer with the parent's node, values and all. A server not advertising RFC 10051 (supported-task-modes) need not keep them, and the behaviour says so: Ox drops both, Zimbra stores both as NEEDS-ACTION, and neither advertises it. 'unknown' by default, as for supported-task-modes: an optional extension is not assumed on a server not probed.", + "default": {"support": "unknown"}, + "extra_keys": { + "values": "The statuses stored as sent.", + "map": "A status, to the one stored instead.", + "refused": "The statuses a task is refused with.", + }, + "links": ["https://datatracker.ietf.org/doc/html/rfc10051"], + }, + "save-load.todo.priority": { + "description": "Each PRIORITY from 0 to 9 (RFC 5545 section 3.8.1.9) is stored as sent. PRIORITY:0 means no priority given, so a server dropping it changes nothing. 'unsupported' when one is dropped or stored as another, 'ungraceful' when a task with one is refused, the worse of the two where both apply; the extra keys say which, with the priorities as integers. Ox keeps 1, 5 and 9 only: it stores 2 as 1, 0 and 3 to 6 as 5, and 7 and 8 as 9.", + "default": {"support": "full"}, + "extra_keys": { + "values": "The priorities stored as sent.", + "map": "A priority, to the one stored instead.", + "refused": "The priorities a task is refused with.", + }, + "links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.1.9"], + }, "save-load.todo.completed-without-status": {"description": "A task with a COMPLETED date-time but no STATUS (RFC 5545 makes neither require the other) is stored with its COMPLETED. 'unsupported' when COMPLETED is dropped (Ox). A server adding STATUS:COMPLETED is fine.", "default": {"support": "full"}}, "save-load.journal": { "description": "The server will even accept journals", @@ -523,6 +563,7 @@ class FeatureSet: "description": "The server reports a calendar object resource under the same URL the client used to store it, so that a client may compare a searched object's URL with one it constructed as '/.ics'. When 'unsupported' it may not, and has to read the URL off the response. Two different things make it 'unsupported'. The server may assign the resource a name of its own choosing - Zimbra, for one, redirects a PUT under any name but '.ics' to '.ics' (see forces_uid_ics). Or the *collection* may not stay at the address it was created at, in which case a constructed object URL is only usable from the address the server reports objects under - and a client is handed either address depending on how it got the Calendar: make_calendar adopts the canonical URL, a calendar listing reports it, while the cal_id shortcut is pure URL arithmetic and never round-trips. That comes in two flavours. OX App Suite exposes a calendar both at the requested cal_id and at an opaque internal 'cal://0/NNN' path, a direct GET on either working, so a constructed URL resolves but is not the URL the server reports. Zimbra instead relocates the collection to a display-name-derived path and leaves an alias at the cal_id that answers PROPFIND but 404s on child objects, so a constructed URL under the cal_id does not resolve at all. That second case is 'create-calendar.stable-url' seen from the object end, and it is read from there rather than measured again here - measuring it made this feature's verdict depend on which address the probe run happened to be holding.", "extra_keys": { "forces_uid_ics": "True when the server names every object .ics whatever name it was PUT to, so a GET of .ics that misses means the object is not there. get_object_by_uid() then does not scan the calendar after a failed UID search.", + "uid_ics_components": "The components the server names .ics whatever name they were PUT to, where it does so for some only: Ox keeps the name of an event and names a task .ics, answering the PUT with 201 and no Location. forces_uid_ics is not set then, since an event may still be under another name.", }, "default": {"support": "full"}, }, @@ -563,8 +604,13 @@ class FeatureSet: "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.8.2"], }, + "save-load.icalendar.x-parameter": { + "description": "An X- parameter (RFC 5545 section 3.2) on a standard property is stored with it, in an event and in a task. 'unsupported' when it is dropped (Ox and Zimbra drop SUMMARY's); the behaviour names the first component it was dropped from.", + "default": {"support": "full"}, + "links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.2"], + }, "save-load.icalendar.unknown-property": { - "description": "A property whose name RFC 5545 does not define, but which is not an X- one either (iana-token syntax, RFC 5545 section 3.8.8.1), is stored with the object. The probe sends ESTIMATED-DURATION, from a draft task extension, on a task. 'unsupported' when it is dropped (Ox).", + "description": "A property whose name RFC 5545 does not define, but which is not an X- one either (iana-token syntax, RFC 5545 section 3.8.8.1), is stored with the object. The probe sends ESTIMATED-DURATION, from RFC 10051, on a task. 'unsupported' when it is dropped (Ox).", "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.8.1"], }, @@ -1775,6 +1821,12 @@ def compare(self, observed): ## zimbra/zcs-foss:latest docker image (Zimbra 8.8, built 2017); upgrades ## have been known to bring regressions, hence the version-stamped name. zimbra_8_8 = { + ## Probed 2026-11-03 by caldav-server-tester, on the docker image + "save-load.todo.status": {"support": "ungraceful", "behaviour": "CANCELLED is refused (401/403)", "values": ["NEEDS-ACTION", "IN-PROCESS", "COMPLETED"], "map": {}, "refused": ["CANCELLED"]}, + "save-load.todo.status.rfc10051": {"support": "unsupported", "behaviour": "PENDING is stored as NEEDS-ACTION; FAILED is stored as NEEDS-ACTION; the server does not advertise RFC 10051", "values": [], "map": {"PENDING": "NEEDS-ACTION", "FAILED": "NEEDS-ACTION"}, "refused": []}, + "supported-task-modes": {"support": "unsupported", "behaviour": "neither the calendar home nor a calendar has CALDAV:supported-task-mode-set"}, + "save-load.icalendar.x-parameter": {"support": "unsupported", "behaviour": "X-CALDAV-SERVER-TESTER on SUMMARY is dropped, in an event"}, + "multiget.deleted": {"support": "broken", "behaviour": "a deleted object is still returned by a multiget, while a GET answers 404"}, ## Measured with caldav-server-tester, 2026-10-27: the UID filter works although search.text does not. 'search.text.uid': {'support': 'full'}, ## Measured with caldav-server-tester, 2026-10-19. @@ -2987,6 +3039,11 @@ def __getattr__(name: str) -> Any: "save-load.icalendar.unknown-property": {"support": "unsupported", "behaviour": "ESTIMATED-DURATION is dropped"}, "save-load.todo.attendee": {"support": "ungraceful", "behaviour": "a task with an ATTENDEE is refused (409)"}, "save-load.todo.completed-without-status": {"support": "unsupported", "behaviour": "COMPLETED is dropped"}, + ## Probed 2026-11-03 by caldav-server-tester + "save-load.todo.status.rfc10051": {"support": "unsupported", "behaviour": "PENDING is dropped; FAILED is dropped; the server does not advertise RFC 10051", "values": [], "map": {}, "refused": []}, + "supported-task-modes": {"support": "unsupported", "behaviour": "neither the calendar home nor a calendar has CALDAV:supported-task-mode-set"}, + "save-load.todo.priority": {"support": "unsupported", "behaviour": "0 is stored as 5; 2 is stored as 1; 3 is stored as 5; 4 is stored as 5; 6 is stored as 5; 7 is stored as 9; 8 is stored as 9", "values": [1, 5, 9], "map": {0: 5, 2: 1, 3: 5, 4: 5, 6: 5, 7: 9, 8: 9}, "refused": []}, + "save-load.icalendar.x-parameter": {"support": "unsupported", "behaviour": "X-CALDAV-SERVER-TESTER on SUMMARY is dropped, in an event"}, ## Measured with caldav-server-tester, 2026-10-28. "save.no-uid-conflict": {"support": "full"}, "save.no-uid-conflict.href-given": {"support": "unsupported"}, @@ -3017,11 +3074,12 @@ def __getattr__(name: str) -> Any: ## OX exposes the calendar both under the requested cal_id and under an ## internal "cal://0/NNN" id, so an object looked up via REPORT comes back ## under a different calendar URL than the one used to PUT them (GET on the - ## original URL still works via an alias). The object's own *name* is - ## preserved; it is the collection that has two addresses, and a client - ## holding the alias therefore cannot compare a searched object's URL with - ## one it constructed. See create-calendar.stable-url for the other half. - 'save-load.stable-url': {'support': 'unsupported'}, + ## original URL still works via an alias). An event keeps its own *name*; + ## it is the collection that has two addresses, and a client holding the + ## alias therefore cannot compare a searched object's URL with one it + ## constructed. See create-calendar.stable-url for the other half. A task + ## is stored as .ics whatever name it was PUT to (201, no Location). + 'save-load.stable-url': {'support': 'unsupported', 'uid_ics_components': ['VTODO']}, ## OX enforces optimistic concurrency: a no-If-Match overwrite PUT is rejected ## with 409 Conflict (etag-conditional save() still works). 'save-load.mutable.if-match-optional': {'support': 'unsupported'}, diff --git a/changes/+todo-values-x-parameter-multiget-deleted.added.md b/changes/+todo-values-x-parameter-multiget-deleted.added.md new file mode 100644 index 00000000..98139c0e --- /dev/null +++ b/changes/+todo-values-x-parameter-multiget-deleted.added.md @@ -0,0 +1 @@ +New server hints: `save-load.todo.status` (RFC 5545's statuses), its child `save-load.todo.status.rfc10051` (PENDING and FAILED) and `save-load.todo.priority`, with the extra keys `values`, `map` and `refused` naming what a task keeps, stores as another, and is refused with; `supported-task-modes`, whether a server advertises RFC 10051 with `CALDAV:supported-task-mode-set`; `save-load.icalendar.x-parameter`; and `multiget.deleted` (Zimbra still returns a deleted object from a calendar-multiget). `save-load.stable-url` has the extra key `uid_ics_components`, for a server naming only some components `.ics` (Ox: tasks). The Ox and Zimbra profiles carry what the probes found. diff --git a/tests/test_compatibility_hints.py b/tests/test_compatibility_hints.py index 4a0fd596..7c55c6d4 100644 --- a/tests/test_compatibility_hints.py +++ b/tests/test_compatibility_hints.py @@ -1197,3 +1197,39 @@ def test_fresh_account_has_no_calendar(self, profile: str) -> None: features = FeatureSet(getattr(compatibility_hints, profile)) assert features.is_supported(self.HAS_CAL) is False + + +class TestTodoStatusHints: + """RFC 5545's statuses and RFC 10051's are hinted apart, so a server keeping + the first and not the second (Ox) is full on the parent.""" + + STATUS = "save-load.todo.status" + RFC10051 = "save-load.todo.status.rfc10051" + + def test_ox_keeps_the_rfc_5545_statuses_only(self) -> None: + features = FeatureSet(ch.ox) + assert features.is_supported(self.STATUS, str) == "full" + assert features.is_supported(self.RFC10051, dict)["values"] == [] + + def test_zimbra_refuses_cancelled_and_maps_the_rfc_10051_statuses(self) -> None: + features = FeatureSet(ch.zimbra_8_8) + assert features.is_supported(self.STATUS, dict)["refused"] == ["CANCELLED"] + assert features.is_supported(self.RFC10051, dict)["map"] == { + "PENDING": "NEEDS-ACTION", + "FAILED": "NEEDS-ACTION", + } + + @pytest.mark.parametrize("profile", ["ox", "zimbra_8_8"]) + def test_a_profile_stating_the_parent_states_the_child(self, profile: str) -> None: + """The child would otherwise inherit the parent's node, values and all.""" + hints = getattr(ch, profile) + assert self.STATUS not in hints or self.RFC10051 in hints + + def test_rfc_10051_statuses_unknown_unless_probed(self) -> None: + """An optional extension: a server not probed is not known to keep them.""" + assert FeatureSet({}).is_supported(self.RFC10051, str) == "unknown" + + def test_task_modes_unknown_unless_probed(self) -> None: + """RFC 10051: absent means unsupported, but an unprobed server is not known to lack it.""" + assert FeatureSet({}).is_supported("supported-task-modes", str) == "unknown" + assert FeatureSet(ch.ox).is_supported("supported-task-modes", str) == "unsupported"