mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-28 14:43:48 +03:00
74f5d66c48
* fileserver: Fix `file` matcher with empty `try_files` Fixes https://github.com/caddyserver/caddy/issues/4146 If `TryFiles` is empty, we fill it with `r.URL.Path`. In this case, this is `/`. Then later, in `prepareFilePath()`, we run the replacer (which turns `{path}` into `/` at that point) but `file` remains the original value (and the placeholder is still the placeholder there). So then `strings.HasSuffix(file, "/")` will be `false` for the placeholder, but `true` for the empty `TryFiles` codepath, because `file` was `/` due to being set to the actual request value beforehand. This means that `suffix` becomes `//` in that case, so after `sanitizedPathJoin`, it becomes `./`, so `strictFileExists`'s `strings.HasSuffix(file, separator)` codepath will return true. I think we should change the `m.TryFiles == nil` codepath to `m.TryFiles = []string{"{http.request.uri.path}"}` for consistency. (And maybe consider hoisting this to `Provision` cause there's no point doing this on every request). I don't think this "optimization" of directly using `r.URL.Path` is so valuable, cause it causes this edgecase with directories. * Update modules/caddyhttp/fileserver/matcher.go Co-authored-by: Matt Holt <mholt@users.noreply.github.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com> |
||
---|---|---|
.. | ||
caddyauth | ||
encode | ||
fileserver | ||
headers | ||
map | ||
push | ||
requestbody | ||
reverseproxy | ||
rewrite | ||
standard | ||
templates | ||
app.go | ||
autohttps.go | ||
caddyhttp.go | ||
celmatcher.go | ||
celmatcher_test.go | ||
errors.go | ||
marshalers.go | ||
matchers.go | ||
matchers_test.go | ||
metrics.go | ||
metrics_test.go | ||
replacer.go | ||
replacer_test.go | ||
responsematchers.go | ||
responsematchers_test.go | ||
responsewriter.go | ||
routes.go | ||
server.go | ||
staticerror.go | ||
staticresp.go | ||
staticresp_test.go | ||
subroute.go | ||
vars.go |