File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -434,8 +434,9 @@ func registerAPIRouter(router *mux.Router) {
434434 router .Methods (http .MethodHead ).HandlerFunc (
435435 collectAPIStats ("headbucket" , maxClients (gz (httpTraceAll (api .HeadBucketHandler )))))
436436 // PostPolicy
437- router .Methods (http .MethodPost ).HeadersRegexp (xhttp .ContentType , "multipart/form-data*" ).HandlerFunc (
438- collectAPIStats ("postpolicybucket" , maxClients (gz (httpTraceHdrs (api .PostPolicyBucketHandler )))))
437+ router .Methods (http .MethodPost ).MatcherFunc (func (r * http.Request , _ * mux.RouteMatch ) bool {
438+ return isRequestPostPolicySignatureV4 (r )
439+ }).HandlerFunc (collectAPIStats ("postpolicybucket" , maxClients (gz (httpTraceHdrs (api .PostPolicyBucketHandler )))))
439440 // DeleteMultipleObjects
440441 router .Methods (http .MethodPost ).HandlerFunc (
441442 collectAPIStats ("deletemultipleobjects" , maxClients (gz (httpTraceAll (api .DeleteMultipleObjectsHandler ))))).Queries ("delete" , "" )
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
2525 "encoding/hex"
2626 "errors"
2727 "io"
28+ "mime"
2829 "net/http"
2930 "net/url"
3031 "strconv"
@@ -74,8 +75,11 @@ func isRequestPresignedSignatureV2(r *http.Request) bool {
7475
7576// Verify if request has AWS Post policy Signature Version '4'.
7677func isRequestPostPolicySignatureV4 (r * http.Request ) bool {
77- return strings .Contains (r .Header .Get (xhttp .ContentType ), "multipart/form-data" ) &&
78- r .Method == http .MethodPost
78+ mediaType , _ , err := mime .ParseMediaType (r .Header .Get (xhttp .ContentType ))
79+ if err != nil {
80+ return false
81+ }
82+ return mediaType == "multipart/form-data" && r .Method == http .MethodPost
7983}
8084
8185// Verify if the request has AWS Streaming Signature Version '4'. This is only valid for 'PUT' operation.
You can’t perform that action at this time.
0 commit comments