Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,22 @@ class VcfExporter {
Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value)
Im.PROTOCOL_QQ -> Impp(QQ, it.value)
Im.PROTOCOL_JABBER -> Impp(JABBER, it.value)
else -> Impp(it.label, it.value)
else -> {
// IMPP URIs use the label as the URI scheme, which only allows
// [a-zA-Z][a-zA-Z0-9+-.]*. Replace any character outside that
// set with a hyphen so labels containing spaces (or other symbols)
// don't throw an IllegalArgumentException and corrupt the export.
val scheme = it.label
.replace(Regex("[^a-zA-Z0-9+\\-.]"), "-")
.let { s ->
when {
s.isEmpty() -> "x-custom"
s.firstOrNull()?.isLetter() != true -> "x-$s"
else -> s
}
}
Impp(scheme, it.value)
}
}

card.addImpp(impp)
Expand Down
Loading