-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Currently, we drop the urn:uuid of incoming vCards:
synctools/lib/src/main/kotlin/at/bitfire/vcard4android/ContactReader.kt
Lines 165 to 166 in 0bb546b
| is Uid -> | |
| c.uid = uriToUid(prop.value) |
synctools/lib/src/main/kotlin/at/bitfire/vcard4android/ContactReader.kt
Lines 133 to 146 in 0bb546b
| val uid = try { | |
| val uri = URI(uriString) | |
| when { | |
| uri.scheme == null -> | |
| uri.schemeSpecificPart | |
| uri.scheme.equals("urn", true) && uri.schemeSpecificPart.startsWith("uuid:", true) -> | |
| uri.schemeSpecificPart.substring(5) | |
| else -> | |
| uriString | |
| } | |
| } catch(e: URISyntaxException) { | |
| logger.warning("Invalid URI for UID: $uriString") | |
| uriString | |
| } |
Then, when generating it again, we take the reduced UID without the prefix:
| contact.uid?.let { vCard.uid = Uid(it) } |
The background is that vCard 3 uses a free-text UID, while vCard 4 either uses URI or free-text, and we don't know in prior whether we have to generate the vCard as vCard 3 or vCard 4.
However the current way of handling that is inconsistent and results in undesired UID modification (urn:uuid removed even when we re-generate as vCard 4; breaks with other URI schemes etc).
As an additional challenge, MEMBER (for groups) only allows URIs. Currently, we use the "reduced" UID and always prepend urn:uuid:. Instead, we should use the correct URI, if it's available and define how we deal with the case that it's not available.
CC @rsto (thanks for notifying us about the problem)