rich7420 commented on code in PR #11387:
URL: https://github.com/apache/ozone/pull/11387#discussion_r4181934646
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/EndpointBase.java:
##########
@@ -470,6 +480,57 @@ protected Map<String, String> getCustomMetadataFromHeaders(
return customMetadata;
}
+ private static String decodeRfc2047MetadataValue(String value) {
+ if (!value.startsWith("=?")) {
+ return value;
+ }
+
+ int charsetEnd = value.indexOf('?', 2);
+ int encodingEnd = charsetEnd < 0 ? -1 : value.indexOf('?', charsetEnd + 1);
+ int encodedTextEnd = encodingEnd < 0
+ ? -1 : value.indexOf("?=", encodingEnd + 1);
+ if (encodedTextEnd != value.length() - 2) {
Review Comment:
`=?UTF-8?Q?a?b?=` passes this check, but `QCodec.decode()` returns `a`. I
reproduced this in a PUT endpoint test: the stored metadata is silently
truncated. Please also check that the first `?` after the encoding token is the
terminating `?=`, preserving the original value otherwise, and add a regression
test alongside the invalid-Base64 case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]