fix(s3): keep a percent sign in a virtual-hosted object key (#6000)

* fix(s3): keep a percent sign in a virtual-hosted object key

A virtual-hosted request for a key such as a%/b failed with 400 or 500.
The same request in path style worked. S3 stores the key as sent in
both styles.

RESTEasy keeps the decoded path of a rewritten request URI and later
decodes it again. S3VirtualHostFilter now escapes the raw path once more,
so routing sees the same path as a path-style request. The request URI
then decodes to /<bucket> plus the raw path, so the virtual-hosted key
check compares against the decoded path.

Fixes #5997

* test(s3): keep only the percent-key cases that guard the fix
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-19 10:57:03 -04:00
1 parent ca47df9ec5
commit 2bb69a030b
6 files changed
+57 -10

No files matched your search

@@ -149,6 +149,20 @@ class S3VirtualHostStyleTest {
@Test
@Order(10)
void keyWithPercentSign() {
String key = "a%/b";
s3.putObject(PutObjectRequest.builder().bucket(BUCKET).key(key).build(),
RequestBody.fromString(CONTENT));
ListObjectsV2Response listed = s3.listObjectsV2(
ListObjectsV2Request.builder().bucket(BUCKET).build());
assertThat(listed.contents()).extracting(S3Object::key).containsExactly(key);
s3.deleteObject(DeleteObjectRequest.builder().bucket(BUCKET).key(key).build());
}
@Test
@Order(11)
void deleteBucket() {
s3.deleteBucket(DeleteBucketRequest.builder().bucket(BUCKET).build());
}