summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-09-07 16:32:41 -0600
committertjpcc <tjp@ctrl-c.club>2023-09-07 16:33:53 -0600
commit195bdb565e9cb46e8d88ee364dcfc96a65a7159a (patch)
treebec5b19c8622e8fd021bab57833f7e5c409abb2b
parent9a31ec4710cc47792a1cf1671d3b03b3d923a6aa (diff)
fix attempt on gopher cgisv1.3.2
-rw-r--r--contrib/cgi/gopher.go11
1 files changed, 7 insertions, 4 deletions
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 {