Fix: text-match filter crashes on structured property (vCard N/ADR)
A CardDAV addressbook-query REPORT with a text-match prop-filter on a structured property (e.g. N or ADR) returned HTTP 500. vobject parses these into Name/Address objects rather than plain strings, so text_match called .lower() on a non-string and raised AttributeError. Coerce non-string values to their text representation before matching. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -578,6 +578,11 @@ def text_match(vobject_item: vobject.base.Component,
|
||||
match_type = filter_.get("match-type", match_type)
|
||||
|
||||
def match(value: str) -> bool:
|
||||
if not isinstance(value, str):
|
||||
# Some properties (e.g. N and ADR in vCard) are parsed by vobject
|
||||
# into structured objects instead of plain strings. Use their text
|
||||
# representation so text-match doesn't crash with AttributeError.
|
||||
value = str(value)
|
||||
value = value.lower()
|
||||
if match_type == "equals":
|
||||
return value == text
|
||||
|
||||
Reference in New Issue
Block a user