Skip to content

Conversation

@rsto
Copy link
Member

@rsto rsto commented Jan 5, 2026

This changes how values of extended properties ("x-properties") are parsed and encoded for vCards. Until now, such values were parsed and encoded as TEXT values. Now they are handled as values of unknown type.

In addition to changing the default value to X-VALUE, this adds a callback to the vCard parser so that libicalvcard callers can specify he value kind per parsed x-property.

Handling these values as TEXT was incorrect: neither vCard 4 (RFC 6350) nor vCard 3 (RFC 2426) defined extended properties to have default value TEXT. This is in contrast to iCalendar which does define their default value to be TEXT (RFC 5545, Section 3.8.8.2).

This was especially problematic because in vCard the COMMA and SEMICOLON characters signify a separator for structured values. Parsing values as TEXT caused these characters to be leniently read as unescaped characters but then become escaped during encoding. As a result, values of x-properties containing these characters differed from their original when encoded, which could change semantics.

It also fixes a couple of bugs when parsing and encoding structured values.

This fixes a couple of bugs when parsing and encoding structured
values: When encoding a structured value, an invalid memory access
had occurred if the first component in a structured value was empty.
Parsing a structured value was broken if the last component was
empty. Escaped COMMA and SEMICOLON characters were incorrectly
parsed as component separators.

This patch fixes all of these and adds regression tests.
@rsto rsto requested a review from ksmurchison January 5, 2026 15:12
@rsto
Copy link
Member Author

rsto commented Jan 5, 2026

Meh, CI fails with an "unused argument" error for one of the tests although we do use the argument in an assert:

assert(data == (void*) 0x1234);

Copy link

@ksmurchison ksmurchison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This changes how values of extended properties ("x-properties") are
parsed and encoded for vCards. Until now, such values were parsed and
encoded as TEXT values. Now they are handled as values of unknown type.

In addition to changing the default value to X-VALUE, this adds a
callback to the vCard parser so that libicalvcard callers can specify
he value kind per parsed x-property.

Handling these values as TEXT was incorrect: neither vCard 4 (RFC 6350)
nor vCard 3 (RFC 2426) defined extended properties to have default
value TEXT. This is in contrast to iCalendar which does define their
default value to be TEXT (RFC 5545, Section 3.8.8.2).

This was especially problematic because in vCard the COMMA and
SEMICOLON characters signify a separator for structured values.
Parsing values as TEXT caused these characters to be leniently read as
unescaped characters but then become escaped during encoding. As a
result, values of x-properties containing these characters differed
from their original when encoded, which could change semantics.
@rsto rsto merged commit c3a9093 into cyrusimap:cyrus Jan 7, 2026
4 of 6 checks passed
@rsto rsto deleted the cyrus-next branch January 7, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants