aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-02-27 12:56:06 +0100
committerSimon Ser <contact@emersion.fr>2020-02-27 12:56:06 +0100
commitea0626d8060ab10005f29a8e9722ea35f58b0ec4 (patch)
tree04ed6dd86bcbed959d4a54a8eafd6b8a0b897c5c /plugins
parent89149b38c8d10d4db457614450517e4ab6d57062 (diff)
downloadalps-ea0626d8060ab10005f29a8e9722ea35f58b0ec4.tar.gz
alps-ea0626d8060ab10005f29a8e9722ea35f58b0ec4.zip
plugins/carddav: check supported vCard versions
Diffstat (limited to 'plugins')
-rw-r--r--plugins/carddav/routes.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/carddav/routes.go b/plugins/carddav/routes.go
index b276944..ccc053c 100644
--- a/plugins/carddav/routes.go
+++ b/plugins/carddav/routes.go
@@ -151,10 +151,16 @@ func registerRoutes(p *plugin) {
fn := ctx.FormValue("fn")
emails := strings.Split(ctx.FormValue("emails"), ",")
- // Some CardDAV servers (e.g. Google) don't support vCard 4.0
- // TODO: get supported formats from server, use highest version
if _, ok := card[vcard.FieldVersion]; !ok {
- card.SetValue(vcard.FieldVersion, "3.0")
+ // Some CardDAV servers (e.g. Google) don't support vCard 4.0
+ var version = "4.0"
+ if !addressBook.SupportsAddressData(vcard.MIMEType, version) {
+ version = "3.0"
+ }
+ if !addressBook.SupportsAddressData(vcard.MIMEType, version) {
+ return fmt.Errorf("upstream CardDAV server doesn't support vCard %v", version)
+ }
+ card.SetValue(vcard.FieldVersion, version)
}
if field := card.Preferred(vcard.FieldFormattedName); field != nil {