1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00
caddy/modules/caddyhttp/fileserver
Matthew Holt fbd6560976
fileserver: Only redirect if filename not rewritten (fix #4205)
This is the more correct implementation of  23dadc0d86 (#4179)... I think. This commit effectively undoes the revert in 8848df9c5d, but with corrections to the logic.

We *do* need to use the original request path (the path the browser knows) for redirects, since they are external, and rewrites are only internal.

However, if the path was rewritten to a non-canonical path, we should not redirect to canonicalize that, since rewrites are intentional by the site owner. Canonicalizing the path involves modifying only the suffix (base element, or filename) of the path. Thus, if a rewrite involves only the prefix (like how handle_path strips a path prefix), then we can (hopefully!) safely redirect using the original URI since the filename was not rewritten.

So basically, if rewrites modify the filename, we should not canonicalize those requests. If rewrites only modify another part of the path (commonly a prefix), we should be OK to redirect.
2021-06-17 09:55:49 -06:00
..
testdata fileserver: Fix try_files for directories; windows fix (#3684) 2020-09-16 18:09:28 -06:00
browse.go fileserver: Only redirect if filename not rewritten (fix #4205) 2021-06-17 09:55:49 -06:00
browsetpl.go fileserver: Browse listing supports dark mode (#4066) 2021-03-19 11:41:02 -06:00
browsetplcontext.go fileserver: Share template logic for both templates and file_server browse (#4093) 2021-04-30 22:17:23 -04:00
browsetplcontext_test.go fileserver: Share template logic for both templates and file_server browse (#4093) 2021-04-30 22:17:23 -04:00
caddyfile.go fileserver: Add status code override (#4076) 2021-04-08 11:09:12 -06:00
command.go cmd: file-server: add --access-log flag (#3454) 2020-05-26 15:04:04 -06:00
matcher.go fileserver: Fix file matcher with empty try_files (#4147) 2021-05-04 09:49:13 -06:00
matcher_test.go fastcgi: Set PATH_INFO to file matcher remainder as fallback (#3739) 2020-12-04 17:12:13 -07:00
staticfiles.go fileserver: Only redirect if filename not rewritten (fix #4205) 2021-06-17 09:55:49 -06:00
staticfiles_test.go fileserver: Improve and clarify file hiding logic (#3844) 2020-11-02 14:20:12 -07:00