From 195bdb565e9cb46e8d88ee364dcfc96a65a7159a Mon Sep 17 00:00:00 2001 From: tjpcc Date: Thu, 7 Sep 2023 16:32:41 -0600 Subject: fix attempt on gopher cgis --- contrib/cgi/gopher.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'contrib') diff --git a/contrib/cgi/gopher.go b/contrib/cgi/gopher.go index 98a3c75..67ea688 100644 --- a/contrib/cgi/gopher.go +++ b/contrib/cgi/gopher.go @@ -34,7 +34,9 @@ func GopherCGIDirectory(pathRoot, fsRoot string, settings *gophermap.FileSystemS return nil } - fullpath, pathinfo, err := resolveGopherCGI(fsRoot, request) + requestPath := strings.Trim(strings.TrimPrefix(request.Path, pathRoot), "/") + + fullpath, pathinfo, err := resolveGopherCGI(fsRoot, requestPath) if err != nil { return gopher.Error(err).Response() } @@ -128,15 +130,16 @@ func runGopherCGI( } doc, _, err := edoc.Compatible(filepath.Dir(fullpath), settings) + if err != nil { + return gopher.Error(err).Response() + } return doc.Response() } return gopher.File(gopher.MenuType, stdout) } -func resolveGopherCGI(fsRoot string, request *sr.Request) (string, string, error) { - reqPath := strings.TrimLeft(request.Path, "/") - +func resolveGopherCGI(fsRoot string, reqPath string) (string, string, error) { segments := append([]string{""}, strings.Split(reqPath, "/")...) fullpath := fsRoot for i, segment := range segments { -- cgit v1.2.3