Skip to content
Permalink
Browse files

Fix panic serving index file if HTTP request is malformed

  • Loading branch information...
mholt committed May 27, 2019
1 parent b590613 commit 14a8ffedd8d424e39006fb5df62d8af005882f96
Showing with 4 additions and 0 deletions.
  1. +4 −0 caddyhttp/httpserver/middleware.go
@@ -117,6 +117,10 @@ func (c ConfigSelector) Select(r *http.Request) (config HandlerConfig) {
// path separator, just like URLs. IndexFle handles path manipulation
// internally for systems that use different path separators.
func IndexFile(root http.FileSystem, fpath string, indexFiles []string) (string, bool) {
if len(fpath) == 0 {
// https://caddy.community/t/panic-runtime-error-index-out-of-range/5781
fpath = "/"
}
if fpath[len(fpath)-1] != '/' || root == nil {
return "", false
}

0 comments on commit 14a8ffe

Please sign in to comment.
You can’t perform that action at this time.