summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/rewrite/rewrite_test.go
diff options
context:
space:
mode:
authorTran Phong <letranphong2k1@gmail.com>2023-05-16 22:16:07 +0700
committerGitHub <noreply@github.com>2023-05-16 09:16:07 -0600
commit13a37688dcdc1ffa8e9322dad0bffac0c0c9893a (patch)
tree2fb5683d5364ec5e5be42a7c90978fec0897b725 /modules/caddyhttp/rewrite/rewrite_test.go
parente8352aef38642c20ff528836b6581094f087eb99 (diff)
rewrite: use escaped path, fix #5278 (#5504)
* use escaped path while rewriting Signed-off-by: TP-O <letranphong2k1@gmail.com> * restore line break --------- Signed-off-by: TP-O <letranphong2k1@gmail.com>
Diffstat (limited to 'modules/caddyhttp/rewrite/rewrite_test.go')
-rw-r--r--modules/caddyhttp/rewrite/rewrite_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/caddyhttp/rewrite/rewrite_test.go b/modules/caddyhttp/rewrite/rewrite_test.go
index 5875983..bb937ec 100644
--- a/modules/caddyhttp/rewrite/rewrite_test.go
+++ b/modules/caddyhttp/rewrite/rewrite_test.go
@@ -60,6 +60,16 @@ func TestRewrite(t *testing.T) {
expect: newRequest(t, "GET", "foo"),
},
{
+ rule: Rewrite{URI: "{http.request.uri}"},
+ input: newRequest(t, "GET", "/bar%3Fbaz?c=d"),
+ expect: newRequest(t, "GET", "/bar%3Fbaz?c=d"),
+ },
+ {
+ rule: Rewrite{URI: "{http.request.uri.path}"},
+ input: newRequest(t, "GET", "/bar%3Fbaz"),
+ expect: newRequest(t, "GET", "/bar%3Fbaz"),
+ },
+ {
rule: Rewrite{URI: "/foo{http.request.uri.path}"},
input: newRequest(t, "GET", "/bar"),
expect: newRequest(t, "GET", "/foo/bar"),
@@ -323,7 +333,7 @@ func TestRewrite(t *testing.T) {
input: newRequest(t, "GET", "/foo/findme%2Fbar"),
expect: newRequest(t, "GET", "/foo/replaced%2Fbar"),
},
-
+
{
rule: Rewrite{PathRegexp: []*regexReplacer{{Find: "/{2,}", Replace: "/"}}},
input: newRequest(t, "GET", "/foo//bar///baz?a=b//c"),