@@ -113,6 +113,11 @@ func TestCrossOriginProtectionPatternBypass(t *testing.T) {
113113 protection := http .NewCrossOriginProtection ()
114114 protection .AddInsecureBypassPattern ("/bypass/" )
115115 protection .AddInsecureBypassPattern ("/only/{foo}" )
116+ protection .AddInsecureBypassPattern ("/no-trailing" )
117+ protection .AddInsecureBypassPattern ("/yes-trailing/" )
118+ protection .AddInsecureBypassPattern ("PUT /put-only/" )
119+ protection .AddInsecureBypassPattern ("GET /get-only/" )
120+ protection .AddInsecureBypassPattern ("POST /post-only/" )
116121 handler := protection .Handler (okHandler )
117122
118123 tests := []struct {
@@ -126,13 +131,23 @@ func TestCrossOriginProtectionPatternBypass(t *testing.T) {
126131 {"non-bypass path without sec-fetch-site" , "/api/" , "" , http .StatusForbidden },
127132 {"non-bypass path with cross-site" , "/api/" , "cross-site" , http .StatusForbidden },
128133
129- {"redirect to bypass path without .." , "/foo/../bypass/bar" , "" , http .StatusOK },
130- {"redirect to bypass path with trailing slash" , "/bypass" , "" , http .StatusOK },
134+ {"redirect to bypass path without .." , "/foo/../bypass/bar" , "" , http .StatusForbidden },
135+ {"redirect to bypass path with trailing slash" , "/bypass" , "" , http .StatusForbidden },
131136 {"redirect to non-bypass path with .." , "/foo/../api/bar" , "" , http .StatusForbidden },
132137 {"redirect to non-bypass path with trailing slash" , "/api" , "" , http .StatusForbidden },
133138
134139 {"wildcard bypass" , "/only/123" , "" , http .StatusOK },
135140 {"non-wildcard" , "/only/123/foo" , "" , http .StatusForbidden },
141+
142+ // https://go.dev/issue/75054
143+ {"no trailing slash exact match" , "/no-trailing" , "" , http .StatusOK },
144+ {"no trailing slash with slash" , "/no-trailing/" , "" , http .StatusForbidden },
145+ {"yes trailing slash exact match" , "/yes-trailing/" , "" , http .StatusOK },
146+ {"yes trailing slash without slash" , "/yes-trailing" , "" , http .StatusForbidden },
147+
148+ {"method-specific hit" , "/post-only/" , "" , http .StatusOK },
149+ {"method-specific miss (PUT)" , "/put-only/" , "" , http .StatusForbidden },
150+ {"method-specific miss (GET)" , "/get-only/" , "" , http .StatusForbidden },
136151 }
137152
138153 for _ , tc := range tests {
0 commit comments