diff options
author | Simon Ser <contact@emersion.fr> | 2020-02-27 12:56:06 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-02-27 12:56:06 +0100 |
commit | ea0626d8060ab10005f29a8e9722ea35f58b0ec4 (patch) | |
tree | 04ed6dd86bcbed959d4a54a8eafd6b8a0b897c5c | |
parent | 89149b38c8d10d4db457614450517e4ab6d57062 (diff) | |
download | alps-ea0626d8060ab10005f29a8e9722ea35f58b0ec4.tar.gz alps-ea0626d8060ab10005f29a8e9722ea35f58b0ec4.zip |
plugins/carddav: check supported vCard versions
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | plugins/carddav/routes.go | 12 |
3 files changed, 12 insertions, 6 deletions
@@ -14,7 +14,7 @@ require ( github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b github.com/emersion/go-smtp v0.12.1 github.com/emersion/go-vcard v0.0.0-20191221110513-5f81fa0d3cc7 - github.com/emersion/go-webdav v0.2.1-0.20200224201645-514296664cee + github.com/emersion/go-webdav v0.2.1-0.20200227113614-abadf534f49a github.com/google/uuid v1.1.1 github.com/gorilla/css v1.0.0 // indirect github.com/labstack/echo/v4 v4.1.15-0.20200203180927-504f39abaf32 @@ -33,8 +33,8 @@ github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0 github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U= github.com/emersion/go-vcard v0.0.0-20191221110513-5f81fa0d3cc7 h1:SE+tcd+0kn0cT4MqTo66gmkjqWHF1Z+Yha5/rhLs/H8= github.com/emersion/go-vcard v0.0.0-20191221110513-5f81fa0d3cc7/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM= -github.com/emersion/go-webdav v0.2.1-0.20200224201645-514296664cee h1:yLluRVLxWJpWN00N+vMNkMUq3KCEU+jdBTXvOh7wXAQ= -github.com/emersion/go-webdav v0.2.1-0.20200224201645-514296664cee/go.mod h1:uSM1VveeKtogBVWaYccTksToczooJ0rrVGNsgnDsr4Q= +github.com/emersion/go-webdav v0.2.1-0.20200227113614-abadf534f49a h1:2AEvZeJdBiMRbcoI4hAtkoymn/7MypOQSKRZV7K0VgE= +github.com/emersion/go-webdav v0.2.1-0.20200227113614-abadf534f49a/go.mod h1:uSM1VveeKtogBVWaYccTksToczooJ0rrVGNsgnDsr4Q= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= 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 { |