Skip to content

Fix vCard import silently dropping properties with a non-item group prefix - #10271

Merged
alecpl merged 1 commit into
roundcube:masterfrom
MiMoHo:held-vcard-group-prefix
Jul 25, 2026
Merged

Fix vCard import silently dropping properties with a non-item group prefix#10271
alecpl merged 1 commit into
roundcube:masterfrom
MiMoHo:held-vcard-group-prefix

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

RFC 6350 permits any group name as a group. prefix on a vCard property (e.g. HOME.EMAIL:..., group1.TEL:...). Roundcube only recognized Apple's item\d. prefix, so a property carrying any other group prefix was silently dropped on import: the email/phone/etc. never appeared in the parsed record.

Root cause

rcube_vcard::cleanup() (program/lib/Roundcube/rcube_vcard.php:608) stripped only the item\d*. prefix from property lines. Any surviving group. prefix (e.g. HOME.EMAIL) was carried into vcard_decode(), which then keyed the value under the literal field name HOME.EMAIL instead of EMAIL. Since that field is not in the fieldmap, the value was discarded.

Fix

Generalize the prefix-stripping regex in cleanup() from /^item\d*\./mi to /^[a-z0-9-]+\./mi, so any RFC 6350 group prefix at the start of a line is removed before decoding. This runs after the existing Apple-specific X-ABRELATEDNAMES / X-ABLabel handling and after the item\d*.X-AB* cruft removal, so item-prefixed Apple label pairing is unaffected. Group names never contain dots and continuation lines begin with whitespace, so the pattern only matches genuine group prefixes.

Testing

Added test_parse_group_prefix in tests/Framework/VCardTest.php, importing a vCard with HOME.EMAIL: and group1.TEL: and asserting both are parsed into the record ($vcard->email[0], and email:other / phone:other in get_assoc()). The test fails on unmodified code and passes after the fix. The full VCardTest suite (15 tests, incl. the existing ITEM1.-prefixed address case) passes, and phpstan level 4 reports no new errors.

@MiMoHo
MiMoHo force-pushed the held-vcard-group-prefix branch from 93f20a3 to 81274d4 Compare July 16, 2026 08:14
@alecpl alecpl added this to the 1.7.3 milestone Jul 25, 2026
@alecpl
alecpl merged commit 2be0199 into roundcube:master Jul 25, 2026
16 of 17 checks passed
alecpl pushed a commit that referenced this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants