fix: allow trailing slash in AWS S3 POST policies (#21612)

This commit is contained in:
cduzer 2025-10-10 20:57:35 +02:00 committed by GitHub
parent ba3c0fd1c7
commit 1b8ac0af9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -75,7 +75,7 @@ func parseCredentialHeader(credElement string, region string, stype serviceType)
if creds[0] != "Credential" {
return ch, ErrMissingCredTag
}
credElements := strings.Split(strings.TrimSpace(creds[1]), SlashSeparator)
credElements := strings.Split(strings.TrimRight(strings.TrimSpace(creds[1]), SlashSeparator), SlashSeparator)
if len(credElements) < 5 {
return ch, ErrCredMalformed
}

View File

@ -236,6 +236,25 @@ func TestParseCredentialHeader(t *testing.T) {
"aws4_request"),
expectedErrCode: ErrNone,
},
// Test Case - 12.
// Test case with right inputs but trailing `/`. Expected to return a valid CredentialHeader.
// "aws4_request" is the valid request version.
{
inputCredentialStr: generateCredentialStr(
"Z7IXGOO6BZ0REAN1Q26I",
sampleTimeStr,
"us-west-1",
"s3",
"aws4_request/"),
expectedCredentials: generateCredentials(
t,
"Z7IXGOO6BZ0REAN1Q26I",
sampleTimeStr,
"us-west-1",
"s3",
"aws4_request"),
expectedErrCode: ErrNone,
},
}
for i, testCase := range testCases {