From 5f9efebeb3a9447312d4838f70c3f0c04ab345bf Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Thu, 8 Dec 2022 09:54:03 +1300 Subject: [PATCH] Bugfix: Append trailing slash to custom webroot for UI & API Fixes #25 --- config/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index f249763..28344c4 100644 --- a/config/config.go +++ b/config/config.go @@ -160,11 +160,12 @@ func VerifyConfig() error { SMTPAuth = a } - if strings.Contains(Webroot, " ") { - return fmt.Errorf("Webroot cannot contain spaces (%s)", Webroot) + validWebrootRe := regexp.MustCompile(`[^0-9a-zA-Z\/-]`) + if validWebrootRe.MatchString(Webroot) { + return fmt.Errorf("Invalid characters in Webroot (%s). Valid chars: a-z, A-Z, 0-9, - and /", Webroot) } - s := path.Join("/", Webroot, "/") + s := strings.TrimRight(path.Join("/", Webroot, "/"), "/") + "/" Webroot = s SMTPTags = []Tag{}