mirror of
https://github.com/caddyserver/caddy.git
synced 2026-03-07 01:25:32 -05:00
rewrite: Force recomputing path when escaped path matches rewrite target
Thank you for the report by @MaherAzzouzi, and the suggested fix!
This commit is contained in:
parent
e06dfcf6ed
commit
fbfb8fc517
@ -247,6 +247,7 @@ func (rewr Rewrite) Rewrite(r *http.Request, repl *caddy.Replacer) bool {
|
||||
} else {
|
||||
r.URL.Path = path
|
||||
}
|
||||
r.URL.RawPath = "" // force recomputing when EscapedPath() is called
|
||||
}
|
||||
if qsStart >= 0 {
|
||||
r.URL.RawQuery = newQuery
|
||||
|
||||
@ -224,6 +224,11 @@ func TestRewrite(t *testing.T) {
|
||||
input: newRequest(t, "GET", "/foo#fragFirst?c=d"),
|
||||
expect: newRequest(t, "GET", "/bar#fragFirst?c=d"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{URI: "/api/admin/panel"},
|
||||
input: newRequest(t, "GET", "/api/admin%2Fpanel"),
|
||||
expect: newRequest(t, "GET", "/api/admin/panel"),
|
||||
},
|
||||
|
||||
{
|
||||
rule: Rewrite{StripPathPrefix: "/prefix"},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user