From cf827673c0574fc905cefe0f030423eac6f0eff4 Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Fri, 14 Jan 2022 12:51:53 +0100 Subject: [PATCH] feature (dav): support for servers who have the username in their URL - #418 In the URL parameters for DAV backends (WebDAV and CalDAV/CardDAV) the %{username} string is interpolated to the URL encoded username. It shouldn't conflict with legitimate URLS as %{ is not a valid URL escape sequence. This is needed for some servers where the URL contains the username such as Cyrus IMAP. --- server/plugin/plg_backend_dav/index.go | 2 +- server/plugin/plg_backend_webdav/index.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/plugin/plg_backend_dav/index.go b/server/plugin/plg_backend_dav/index.go index fcb93175..08400bed 100644 --- a/server/plugin/plg_backend_dav/index.go +++ b/server/plugin/plg_backend_dav/index.go @@ -41,7 +41,7 @@ func (this Dav) Init(params map[string]string, app *App) (IBackend, error) { return backend, nil } backend := Dav{ - url: params["url"], + url: strings.ReplaceAll(params["url"], "%{username}", url.PathEscape(params["username"])), which: params["type"], params: params, } diff --git a/server/plugin/plg_backend_webdav/index.go b/server/plugin/plg_backend_webdav/index.go index e6b1c82a..e85cd557 100644 --- a/server/plugin/plg_backend_webdav/index.go +++ b/server/plugin/plg_backend_webdav/index.go @@ -35,7 +35,7 @@ func (w WebDav) Init(params map[string]string, app *App) (IBackend, error) { } backend := WebDav{ params: &WebDavParams{ - params["url"], + strings.ReplaceAll(params["url"], "%{username}", url.PathEscape(params["username"])), params["username"], params["password"], params["path"],