From e7457b43e4703080ae8713ada798ce3e20b83690 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Mon, 8 Nov 2021 15:45:03 -0500 Subject: caddyhttp: Sanitize the path before evaluating path matchers (#4407) --- modules/caddyhttp/matchers_test.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'modules/caddyhttp/matchers_test.go') 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 @@ -257,6 +257,21 @@ func TestPathMatcher(t *testing.T) { input: "/foo/BAR.txt", 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: "/", @@ -326,15 +341,30 @@ 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/", -- cgit v1.2.3