From b16fe0b8d4d9861c9625ee849c76b0bf946805a9 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Wed, 8 Feb 2023 20:32:17 +0100 Subject: [PATCH] Absolutise DocBase before trying to absolutise anything else relative to it. --- config.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config.go b/config.go index 0d3fab4..cd5710c 100644 --- a/config.go +++ b/config.go @@ -92,6 +92,15 @@ func getConfig(filename string) (Config, error) { return config, errors.New("Invalid DirectorySort value.") } + // Absolutise DocBase + if(!filepath.IsAbs(config.DocBase)) { + abs, err := filepath.Abs(config.DocBase) + if err != nil { + return config, err + } + config.DocBase = abs + } + // Absolutise CGI paths for index, cgiPath := range config.CGIPaths { if(!filepath.IsAbs(cgiPath)) { @@ -110,6 +119,13 @@ func getConfig(filename string) (Config, error) { } config.CGIPaths = cgiPaths + // Absolutise SCGI paths + for index, scgiPath := range config.SCGIPaths { + if(!filepath.IsAbs(scgiPath)) { + config.SCGIPaths[index] = filepath.Join(config.DocBase, scgiPath) + } + } + // Validate redirects for _, value := range config.TempRedirects { if strings.Contains(value, "://") && !strings.HasPrefix(value, "gemini://") {