mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 07:35:51 +08:00
Prevent information loss, i.e. the encoded form that was sent by the client, when using URL strip/replace.
This commit is contained in:
@ -199,6 +199,11 @@ func TestRewrite(t *testing.T) {
|
||||
input: newRequest(t, "GET", "/prefix/foo/bar"),
|
||||
expect: newRequest(t, "GET", "/foo/bar"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{StripPathPrefix: "/prefix"},
|
||||
input: newRequest(t, "GET", "/prefix/foo%2Fbar"),
|
||||
expect: newRequest(t, "GET", "/foo%2Fbar"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{StripPathPrefix: "/prefix"},
|
||||
input: newRequest(t, "GET", "/foo/prefix/bar"),
|
||||
@ -215,6 +220,11 @@ func TestRewrite(t *testing.T) {
|
||||
input: newRequest(t, "GET", "/foo/bar/suffix"),
|
||||
expect: newRequest(t, "GET", "/foo/bar/"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{StripPathSuffix: "suffix"},
|
||||
input: newRequest(t, "GET", "/foo%2Fbar/suffix"),
|
||||
expect: newRequest(t, "GET", "/foo%2Fbar/"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{StripPathSuffix: "/suffix"},
|
||||
input: newRequest(t, "GET", "/foo/suffix/bar"),
|
||||
@ -231,6 +241,11 @@ func TestRewrite(t *testing.T) {
|
||||
input: newRequest(t, "GET", "/foo/findme/bar"),
|
||||
expect: newRequest(t, "GET", "/foo/replaced/bar"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{URISubstring: []replacer{{Find: "findme", Replace: "replaced"}}},
|
||||
input: newRequest(t, "GET", "/foo/findme%2Fbar"),
|
||||
expect: newRequest(t, "GET", "/foo/replaced%2Fbar"),
|
||||
},
|
||||
} {
|
||||
// copy the original input just enough so that we can
|
||||
// compare it after the rewrite to see if it changed
|
||||
|
Reference in New Issue
Block a user