@marcel91200 / caddy Mirror · read-only / commits / 78b5356f
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 01:30 UTC

fileserver: do not double-escape paths (#4447)

Mohammed Al Sahaf committed Dec 11, 2021 at 17:26 UTC 78b5356f2b1945a90de1ef7f2c7669d82098edbd
2 files changed +3 -5
modules/caddyhttp/caddyhttp.go
-2
@@ -20,7 +20,6 @@ import (
20 "io"
21 "net"
22 "net/http"
23 - "net/url"
23 "path/filepath"
24 "strconv"
25 "strings"
@@ -228,7 +227,6 @@ func StatusCodeMatches(actual, configured int) bool {
227 // never be outside of root. The resulting path can be used
228 // with the local file system.
229 func SanitizedPathJoin(root, reqPath string) string {
231 - reqPath, _ = url.PathUnescape(reqPath)
230 if root == "" {
231 root = "."
232 }
modules/caddyhttp/fileserver/browsetplcontext.go
+3 -3
@@ -43,11 +43,9 @@ func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, root
43
44 isDir := f.IsDir() || isSymlinkTargetDir(f, root, urlPath)
45
46 - u := url.URL{Path: url.PathEscape(name)}
47 -
46 // add the slash after the escape of path to avoid escaping the slash as well
47 if isDir {
50 - u.Path += "/"
48 + name += "/"
49 dirCount++
50 } else {
51 fileCount++
@@ -67,6 +65,8 @@ func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, root
65 // was already set above.
66 }
67
68 + u := url.URL{Path: "./" + name} // prepend with "./" to fix paths with ':' in the name
69 +
70 fileInfos = append(fileInfos, fileInfo{
71 IsDir: isDir,
72 IsSymlink: fileIsSymlink,