Add CardDAV supported-address-data, update vCards to 4.0 (#1948)
* Add CardDAV supported-address-data, update vCards to 4.0 - radicale/app/propfind.py: Add CS:getctag and CR:supported-address-data properties to VADDRESSBOOK collections in allprop responses; implement CR:supported-address-data handler that advertises vCard 4.0 as preferred format with 3.0 fallback per RFC 6352 section 6.2.2 - radicale/tests/static/contact1.vcf: Update from vCard 3.0 to 4.0 format - radicale/tests/static/contact_multiple.vcf: Update both contact entries from vCard 3.0 to 4.0 format - radicale/tests/static/contact_photo_with_data_uri.vcf: Update from vCard 3.0 to 4.0 format; change PHOTO property from 3.0 syntax with ENCODING=b and TYPE parameters to 4.0 data URI syntax * Conditionally offer vCard 4.0 based on vobject version - Add vobject_supports_vcard4() helper function in utils.py - Modify propfind.py to only advertise vCard 4.0 if vobject >= 1.0.0 - Add vCard 3.0 static test files for fallback testing - Add tests for both vCard 3.0 and 4.0 contacts (v4 tests skipped if vobject < 1.0.0) - Add propfind tests for CR:supported-address-data property 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Default vCard fixtures to v3.0, add explicit v4 files - contact1.vcf: Change VERSION from 4.0 to 3.0 to make vCard 3.0 the default test fixture format, since vCard 3.0 is more widely supported - contact1_v3.vcf: Delete file as contact1.vcf now serves as the v3.0 fixture - contact1_v4.vcf: Add new file with VERSION 4.0 for explicit vCard 4.0 testing with vobject >= 1.0.0 - contact_multiple.vcf: Change VERSION from 4.0 to 3.0 for both contacts to align with new default - contact_multiple_v3.vcf: Delete file as contact_multiple.vcf now serves as the v3.0 fixture - contact_multiple_v4.vcf: Add new file with VERSION 4.0 for both contacts - contact_photo_with_data_uri.vcf: Change VERSION from 4.0 to 3.0 and update PHOTO property to use v3.0 format with ENCODING=b;TYPE=png parameters - contact_photo_with_data_uri_v3.vcf: Delete file as contact_photo_with_data_uri.vcf now serves as the v3.0 fixture - contact_photo_with_data_uri_v4.vcf: Add new file with VERSION 4.0 and v4.0 PHOTO data URI format - test_base.py: Update test methods to use renamed fixture files, with v3.0 tests using default fixtures and v4.0 tests using explicit _v4.vcf files --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,8 @@ import xml.etree.ElementTree as ET
|
||||
from http import client
|
||||
from typing import Dict, Iterable, Iterator, List, Optional, Sequence, Tuple
|
||||
|
||||
from radicale import httputils, pathutils, rights, storage, types, xmlutils
|
||||
from radicale import (httputils, pathutils, rights, storage, types, utils,
|
||||
xmlutils)
|
||||
from radicale.app.base import Access, ApplicationBase
|
||||
from radicale.log import logger
|
||||
|
||||
@@ -135,6 +136,10 @@ def xml_propfind_response(
|
||||
props.append(xmlutils.make_clark("CS:getctag"))
|
||||
props.append(
|
||||
xmlutils.make_clark("C:supported-calendar-component-set"))
|
||||
if collection.tag == "VADDRESSBOOK":
|
||||
props.append(xmlutils.make_clark("CS:getctag"))
|
||||
props.append(
|
||||
xmlutils.make_clark("CR:supported-address-data"))
|
||||
|
||||
meta = collection.get_meta()
|
||||
for tag in meta:
|
||||
@@ -188,6 +193,21 @@ def xml_propfind_response(
|
||||
element.append(comp)
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("CR:supported-address-data"):
|
||||
if is_collection and is_leaf and collection.tag == "VADDRESSBOOK":
|
||||
# Advertise supported vCard versions per RFC 6352 section 6.2.2
|
||||
# vCard 4.0 requires vobject >= 1.0.0
|
||||
versions: Sequence[str] = (("4.0", "3.0")
|
||||
if utils.vobject_supports_vcard4()
|
||||
else ("3.0",))
|
||||
for version in versions:
|
||||
address_data_type = ET.Element(
|
||||
xmlutils.make_clark("CR:address-data-type"))
|
||||
address_data_type.set("content-type", "text/vcard")
|
||||
address_data_type.set("version", version)
|
||||
element.append(address_data_type)
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("D:current-user-principal"):
|
||||
if user:
|
||||
child_element = ET.Element(xmlutils.make_clark("D:href"))
|
||||
|
||||
Reference in New Issue
Block a user