diff options
author | Antoni Sawicki <tenox@google.com> | 2022-08-30 01:29:11 -0700 |
---|---|---|
committer | Antoni Sawicki <tenox@google.com> | 2022-08-30 01:29:11 -0700 |
commit | d62e7206bc090409386bd684fef6f3043bbc55a8 (patch) | |
tree | 1e909b5cd42183748a77af8076332b2657061920 | |
parent | 625329901d6c82ad3faf10c9c99b084c686fbba0 (diff) | |
download | wfm-d62e7206bc090409386bd684fef6f3043bbc55a8.tar.gz |
fix path prefix
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | dir.go | 2 | ||||
-rw-r--r-- | handlers.go | 4 | ||||
-rw-r--r-- | wfm.go | 2 |
4 files changed, 5 insertions, 4 deletions
@@ -9,6 +9,7 @@ * Use custom FS implementation to resolve and deny symlinks outside of srv directory https://github.com/crazcalm/go/commit/8b0b644cd02c59fe2461908304c44d64e8be431e * use direct url path instead of ?dir=xxx&file=yyyy use /prefix/dir/file +* perhaps default action should check if target is file or dir and run disp or list files? ## Security * seperate prefix for admin/rw users eg /admin with readonly on / @@ -58,7 +58,7 @@ func (r *wfmRequest) listFiles(hi string) { z++ qeFile := url.QueryEscape(f.Name()) heFile := html.EscapeString(f.Name()) - nUrl := *wfmPfx + `/` + qeDir + `/` + qeFile + nUrl := *wfmPfx + qeDir + `/` + qeFile if r.eSort != "" { nUrl += `?sort=` + r.eSort } diff --git a/handlers.go b/handlers.go index d43752c..bc191a0 100644 --- a/handlers.go +++ b/handlers.go @@ -75,14 +75,14 @@ func wfmMain(w http.ResponseWriter, r *http.Request) { wfm.saveText(r.FormValue("text")) return case r.FormValue("up") != "": - up := *wfmPfx + "/" + url.QueryEscape(filepath.Dir(wfm.uDir)) + up := *wfmPfx + url.QueryEscape(filepath.Dir(wfm.uDir)) if wfm.eSort != "" { up += "?sort=" + wfm.eSort } redirect(w, up) return case r.FormValue("refresh") != "": - re := *wfmPfx + "/" + url.QueryEscape(wfm.uDir) + re := *wfmPfx + url.QueryEscape(wfm.uDir) if wfm.eSort != "" { re += "?sort=" + wfm.eSort } @@ -38,7 +38,7 @@ var ( showDot = flag.Bool("show_dot", false, "show dot files and folders") listArc = flag.Bool("list_archive_contents", false, "list contents of archives (expensive!)") rateLim = flag.Int("rate_limit", 0, "rate limit for upload/download in MB/s, 0 no limit") - wfmPfx = flag.String("prefix", "/", "Default url prefix for WFM access") + wfmPfx = flag.String("prefix", "/", "Default url prefix for WFM access, eg.: /files") docSrv = flag.String("doc_srv", "", "Serve regular http files, fsdir:prefix, eg /var/www/:/home/") cacheCtl = flag.String("cache_ctl", "no-cache", "HTTP Header Cache Control") robots = flag.Bool("robots", false, "allow robots") |