Russole commented on code in PR #11387:
URL: https://github.com/apache/ozone/pull/11387#discussion_r4225718934
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/EndpointBase.java:
##########
@@ -470,6 +480,58 @@ 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
+ || value.indexOf('?', encodingEnd + 1) != encodedTextEnd) {
+ return value;
Review Comment:
For malformed RFC 2047 values, should we return the original value instead
of decoding it? For example, `=?UTF-8?Q??=` currently becomes an empty string.
--
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]