summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers_test.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-11-08 15:45:03 -0500
committerGitHub <noreply@github.com>2021-11-08 13:45:03 -0700
commite7457b43e4703080ae8713ada798ce3e20b83690 (patch)
treea02db22f8e7ba9c15a3aae5c2551c76ddf7e0434 /modules/caddyhttp/matchers_test.go
parentf376a38b254a4fa469df10914180c2ebab3e707e (diff)
caddyhttp: Sanitize the path before evaluating path matchers (#4407)
Diffstat (limited to 'modules/caddyhttp/matchers_test.go')
-rw-r--r--modules/caddyhttp/matchers_test.go34
1 files changed, 32 insertions, 2 deletions
diff --git a/modules/caddyhttp/matchers_test.go b/modules/caddyhttp/matchers_test.go
index 2ec7039..f394921 100644
--- a/modules/caddyhttp/matchers_test.go
+++ b/modules/caddyhttp/matchers_test.go
@@ -258,6 +258,21 @@ func TestPathMatcher(t *testing.T) {
expect: true,
},
{
+ match: MatchPath{"/foo*"},
+ input: "//foo/bar",
+ expect: true,
+ },
+ {
+ match: MatchPath{"/foo*"},
+ input: "//foo",
+ expect: true,
+ },
+ {
+ match: MatchPath{"/foo*"},
+ input: "/%2F/foo",
+ expect: true,
+ },
+ {
match: MatchPath{"*"},
input: "/",
expect: true,
@@ -326,16 +341,31 @@ func TestPathREMatcher(t *testing.T) {
expect: true,
},
{
- match: MatchPathRE{MatchRegexp{Pattern: "/foo"}},
+ match: MatchPathRE{MatchRegexp{Pattern: "^/foo"}},
input: "/foo",
expect: true,
},
{
- match: MatchPathRE{MatchRegexp{Pattern: "/foo"}},
+ match: MatchPathRE{MatchRegexp{Pattern: "^/foo"}},
input: "/foo/",
expect: true,
},
{
+ match: MatchPathRE{MatchRegexp{Pattern: "^/foo"}},
+ input: "//foo",
+ expect: true,
+ },
+ {
+ match: MatchPathRE{MatchRegexp{Pattern: "^/foo"}},
+ input: "//foo/",
+ expect: true,
+ },
+ {
+ match: MatchPathRE{MatchRegexp{Pattern: "^/foo"}},
+ input: "/%2F/foo/",
+ expect: true,
+ },
+ {
match: MatchPathRE{MatchRegexp{Pattern: "/bar"}},
input: "/foo/",
expect: false,