summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
authorMohammed Al Sahaf <msaa1990@gmail.com>2021-12-11 17:26:21 +0300
committerGitHub <noreply@github.com>2021-12-11 09:26:21 -0500
commit78b5356f2b1945a90de1ef7f2c7669d82098edbd (patch)
tree0e81d6cb2f48b5387cfee47c9a955afc32dde096 /modules/caddyhttp/fileserver
parent6f9b6ad78e6b9a40afbf12e53017e39abee90a6d (diff)
fileserver: do not double-escape paths (#4447)
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/browsetplcontext.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/caddyhttp/fileserver/browsetplcontext.go b/modules/caddyhttp/fileserver/browsetplcontext.go
index b1b8e9e..87156d4 100644
--- a/modules/caddyhttp/fileserver/browsetplcontext.go
+++ b/modules/caddyhttp/fileserver/browsetplcontext.go
@@ -43,11 +43,9 @@ func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, root
isDir := f.IsDir() || isSymlinkTargetDir(f, root, urlPath)
- u := url.URL{Path: url.PathEscape(name)}
-
// add the slash after the escape of path to avoid escaping the slash as well
if isDir {
- u.Path += "/"
+ name += "/"
dirCount++
} else {
fileCount++
@@ -67,6 +65,8 @@ func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, root
// was already set above.
}
+ u := url.URL{Path: "./" + name} // prepend with "./" to fix paths with ':' in the name
+
fileInfos = append(fileInfos, fileInfo{
IsDir: isDir,
IsSymlink: fileIsSymlink,