From e85d1713e8d9e3b9e92aeb72daf424f5cb48c89f Mon Sep 17 00:00:00 2001 From: Rudi Date: Mon, 5 Aug 2024 17:52:15 +0200 Subject: [PATCH 1/4] Add skip bucket/region/object name validation as special usecase (#1576) --- api/src/main/java/io/minio/BucketArgs.java | 12 +++++++++++- api/src/main/java/io/minio/ObjectArgs.java | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/io/minio/BucketArgs.java b/api/src/main/java/io/minio/BucketArgs.java index a7877eb10..c50bcdfda 100644 --- a/api/src/main/java/io/minio/BucketArgs.java +++ b/api/src/main/java/io/minio/BucketArgs.java @@ -39,9 +39,13 @@ public abstract static class Builder, A extends BucketAr extends BaseArgs.Builder { private static final Pattern BUCKET_NAME_REGEX = Pattern.compile("^[a-z0-9][a-z0-9\\.\\-]{1,61}[a-z0-9]$"); + protected boolean skipValidation = false; protected void validateBucketName(String name) { validateNotNull(name, "bucket name"); + if (skipValidation) { + return; + } if (!BUCKET_NAME_REGEX.matcher(name).find()) { throw new IllegalArgumentException( @@ -63,7 +67,7 @@ protected void validateBucketName(String name) { } private void validateRegion(String region) { - if (region != null && !HttpUtils.REGION_REGEX.matcher(region).find()) { + if (!skipValidation && region != null && !HttpUtils.REGION_REGEX.matcher(region).find()) { throw new IllegalArgumentException("invalid region " + region); } } @@ -80,6 +84,12 @@ public B bucket(String name) { return (B) this; } + @SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class. + public B skipValidation(boolean skipValidation) { + this.skipValidation = skipValidation; + return (B) this; + } + @SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class. public B region(String region) { validateRegion(region); diff --git a/api/src/main/java/io/minio/ObjectArgs.java b/api/src/main/java/io/minio/ObjectArgs.java index 60758c7ed..1d7759338 100644 --- a/api/src/main/java/io/minio/ObjectArgs.java +++ b/api/src/main/java/io/minio/ObjectArgs.java @@ -43,6 +43,9 @@ public abstract static class Builder, A extends ObjectAr extends BucketArgs.Builder { protected void validateObjectName(String name) { validateNotEmptyString(name, "object name"); + if (skipValidation) { + return; + } for (String token : name.split("/")) { if (token.equals(".") || token.equals("..")) { throw new IllegalArgumentException( From 85b4f65ecef5a327083f5019faa994763efedb30 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Sat, 17 Aug 2024 16:46:17 +0530 Subject: [PATCH 2/4] SignV4: trim leading/trailing spaces in header value (#1578) Signed-off-by: Bala.FA --- api/src/main/java/io/minio/Signer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/io/minio/Signer.java b/api/src/main/java/io/minio/Signer.java index 4752a76d6..c45f11f1a 100644 --- a/api/src/main/java/io/minio/Signer.java +++ b/api/src/main/java/io/minio/Signer.java @@ -134,12 +134,14 @@ private void setCanonicalHeaders(Set 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(","))); } From 309d4296248e4adf8e0b881895a6f9ea05b9c1aa Mon Sep 17 00:00:00 2001 From: Minio Trusted Date: Sat, 17 Aug 2024 13:24:51 +0000 Subject: [PATCH 3/4] Release version 8.5.12 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1624a7371..512288f07 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,19 @@ Java 1.8 or above. io.minio minio - 8.5.11 + 8.5.12 ``` ## Gradle usage ``` dependencies { - implementation("io.minio:minio:8.5.11") + implementation("io.minio:minio:8.5.12") } ``` ## JAR download -The latest JAR can be downloaded from [here](https://repo1.maven.org/maven2/io/minio/minio/8.5.11/) +The latest JAR can be downloaded from [here](https://repo1.maven.org/maven2/io/minio/minio/8.5.12/) ## Quick Start Example - File Uploader This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket. @@ -92,12 +92,12 @@ public class FileUploader { #### Compile FileUploader ```sh -$ javac -cp minio-8.5.11-all.jar FileUploader.java +$ javac -cp minio-8.5.12-all.jar FileUploader.java ``` #### Run FileUploader ```sh -$ java -cp minio-8.5.11-all.jar:. FileUploader +$ java -cp minio-8.5.12-all.jar:. FileUploader '/home/user/Photos/asiaphotos.zip' is successfully uploaded as object 'asiaphotos-2015.zip' to bucket 'asiatrip'. $ mc ls play/asiatrip/ From ef85db96a0ac02a201ccc3b5fdd7964f076e017a Mon Sep 17 00:00:00 2001 From: Minio Trusted Date: Sat, 17 Aug 2024 13:28:46 +0000 Subject: [PATCH 4/4] Update version to next release --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2fcb7c066..7fdf71b21 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ apply plugin: "de.marcphilipp.nexus-publish" allprojects { group = 'io.minio' - version = '8.5.12' + version = '8.5.13' if (!project.hasProperty('release')) { version += '-DEV' }