aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoni Sawicki <tenox@google.com>2022-08-30 01:29:11 -0700
committerAntoni Sawicki <tenox@google.com>2022-08-30 01:29:11 -0700
commitd62e7206bc090409386bd684fef6f3043bbc55a8 (patch)
tree1e909b5cd42183748a77af8076332b2657061920
parent625329901d6c82ad3faf10c9c99b084c686fbba0 (diff)
downloadwfm-d62e7206bc090409386bd684fef6f3043bbc55a8.tar.gz
fix path prefix
-rw-r--r--TODO.md1
-rw-r--r--dir.go2
-rw-r--r--handlers.go4
-rw-r--r--wfm.go2
4 files changed, 5 insertions, 4 deletions
diff --git a/TODO.md b/TODO.md
index 06cf89b..e9ee6c2 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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 /
diff --git a/dir.go b/dir.go
index 6d940b4..b0b01ab 100644
--- a/dir.go
+++ b/dir.go
@@ -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
}
diff --git a/wfm.go b/wfm.go
index ebfe7f3..4a5fcae 100644
--- a/wfm.go
+++ b/wfm.go
@@ -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")