Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public static S3Url parse(String s3Url) throws IllegalArgumentException {
boolean s3PathStyle = false;

for (String param : params) {
String[] keyValue = param.split("=");
// Only split on the first '=' so that values containing '=' (e.g. base64-encoded
// access/secret keys, which may include '=' padding) are preserved.
String[] keyValue = param.split("=", 2);
if (keyValue.length != 2) {
throw new IllegalArgumentException("Invalid parameter format: " + param);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ void parseTest() {

}

@Test
void parseWithEqualsSignInCredentials() {
// base64-encoded secret keys frequently contain '=' (padding) and '/' characters.
// The value must be preserved verbatim instead of being split on every '='.
String secretKey = "abc/def+ghi==";
String s3Url = "s3://s3.us-east-1.amazonaws.com?s3-access-key=AKIA=EXAMPLE&s3-secret-key=" + secretKey
+ "&s3-region=us-east-1&s3-endpoint-protocol=https&s3-data-bucket=data&s3-ops-bucket=ops&cluster-id=abc";
S3Url s3UrlObj = S3Url.parse(s3Url);
assertEquals("AKIA=EXAMPLE", s3UrlObj.getS3AccessKey());
assertEquals(secretKey, s3UrlObj.getS3SecretKey());
assertEquals("us-east-1", s3UrlObj.getS3Region());
}

@Test
void parseS3UrlValFromArgs() {
String s3Url = "s3://s3.cn-northwest-1.amazonaws.com.cn?s3-access-key=xxx&s3-secret-key=yyy&s3-region=cn-northwest-1&s3-endpoint-protocol=https&s3-data-bucket=wanshao-test&s3-ops-bucket=automq-ops-bucket&cluster-id=fZGPJht6Rf-o7WgrUakLxQ";
Expand Down
Loading