Repository navigation
Conversation
Signed-off-by: F64116045 <[email protected]>
Signed-off-by: F64116045 <[email protected]>
|
The original |
| int encodingEnd = charsetEnd < 0 ? -1 : value.indexOf('?', charsetEnd + 1); | ||
| int encodedTextEnd = encodingEnd < 0 | ||
| ? -1 : value.indexOf("?=", encodingEnd + 1); | ||
| if (encodedTextEnd != value.length() - 2) { |
There was a problem hiding this 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.
There was a problem hiding this comment.
thanks for the catch! fixed.
Signed-off-by: F64116045 <[email protected]>
Russole
left a comment
There was a problem hiding this comment.
Thanks @F64116045 for the patch. Left some comment.
| ? -1 : value.indexOf("?=", encodingEnd + 1); | ||
| if (encodedTextEnd != value.length() - 2 | ||
| || value.indexOf('?', encodingEnd + 1) != encodedTextEnd) { | ||
| return value; |
There was a problem hiding this 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.
There was a problem hiding this comment.
Oops I missed that case, thanks for catching it.
Also I checked a few other malformed values while fixing it, found similar issues, and added tests for those too.
|
Thanks for the patch. I would like to defer merging this after #11735, which will (hopefully) allow skipping most integration tests for S3-only changes. |
Sure. Also thanks for all your recent work on improving CI! |
|
@peterxcli Thanks for the question
Actually we’re already using Ozone’s existing Commons Codec here for decoding and encoding. I also just looked into |

What changes were proposed in this pull request?
The ceph/s3-tests
test_object_set_get_unicode_metadataexposed that S3 Gateway does not handle non-ASCII user metadata correctly.Investigation showed that S3 uses RFC 2047 for non-ASCII
x-amz-meta-*values. Ozone currently stores encoded values as ordinary text and does not encode them when returning response headers.This patch decodes RFC 2047 Q/B values before storing metadata and encodes non-ASCII values in GET and HEAD responses.
References:
Note:
I kept this PR to the single encoded-word case so we can agree on the basic read&write behavior first.
Multiple words and long values need more work. If this direction looks good, I’ll take those on in a follow-up.
What is the link to the Apache JIRA?
https://issues.apache.org/jira/browse/HDDS-16672
How was this patch tested?
CI: https://github.com/F64116045/ozone/actions/runs/37118609154
Uploaded an object with this RFC 2047 encoded
cafémetadata:x-amz-meta-meta1: =?UTF-8?B?Y2Fmw6k=?=The same request was tested against Ozone before and after this patch, and against S3.
B and Q are two RFC 2047 representations of the same
cafévalue.cafécafécafécafé