Skip to content

Commit

Permalink
SignV4: trim leading/trailing spaces in header value (#1578)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored Aug 17, 2024
1 parent e85d171 commit 85b4f65
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/src/main/java/io/minio/Signer.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ private void setCanonicalHeaders(Set<String> ignored_headers) {
// https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
// * Header having multiple values should be converted to comma separated values.
// * Multi-spaced value of header should be trimmed to single spaced value.
// * Trim leading/trailing spaces in header value (As OkHttp trims leading/trailing spaces
// automatically, this is added for completion).
this.canonicalHeaders.put(
signedHeader,
headers.values(name).stream()
.map(
value -> {
return value.replaceAll("( +)", " ");
return value.replaceAll("( +)", " ").trim();
})
.collect(Collectors.joining(",")));
}
Expand Down

0 comments on commit 85b4f65

Please sign in to comment.