HDDS-15600. Fix ListObjects response for encoding-type, empty delimiter, and control-character prefix#10586
HDDS-15600. Fix ListObjects response for encoding-type, empty delimiter, and control-character prefix#10586Gargi-jais11 wants to merge 4 commits into
Conversation
…rol-character prefix
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @Gargi-jais11 for the patch.
chungen0126
left a comment
There was a problem hiding this comment.
Thanks @Gargi-jais11 for working on this. Overall, looks good to me. Just a nit.
|
@ivandika3 please review this patch. |
Russole
left a comment
There was a problem hiding this comment.
Thanks @Gargi-jais11 for the patch. I’ve left a few review comments.
| if (prefixSpecified) { | ||
| response.setPrefix(EncodingTypeObject.createNullable(prefix, null)); | ||
| } |
There was a problem hiding this comment.
Prefix should also be encoded when encoding-type=url is specified.
AWS docs say EncodingType applies to Delimiter, Prefix, Key, and StartAfter:
https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#AmazonS3-ListObjectsV2-response-EncodingType
Local test:
aws s3api list-objects \
--bucket buck1 \
--prefix $'\n' \
--encoding-type url \
--endpoint-url http://localhost:9878/Actual:
"Prefix": "\n"Expected:
"Prefix": "%0A"Looks like Prefix is created with a null encoding type here. Should this use encodingType instead?
What changes were proposed in this pull request?
Ozone S3 Gateway fails s3-tests ListObjects cases that AWS S3 passes:
test_bucket_list_encoding_basic— With EncodingType=url, keys and CommonPrefixes containing spaces are encoded with + (Java URLEncoder form encoding) instead of AWS-style %20.Example: prefix quux ab/ is returned as quux+ab/ but should be quux%20ab/.
test_bucket_list_delimiter_empty— When Delimiter='' is sent, listing behavior is correct (all keys returned, no CommonPrefixes), but the response incorrectly includes a Delimiter field. AWS omits Delimiter from the XML when the client passes an empty delimiter.test_bucket_list_prefix_unreadable— ListObjects with Prefix='\x0a' (newline) should echo the prefix in the response and return empty Contents/CommonPrefixes. Ozone may not preserve or echo the control-character prefix correctly.https://ozone.s3.peterxcli.dev/#latest-run-section
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15600
How was this patch tested?
Before fix:
3 echoed prefix always url-encoded:
After fix: