From: Tom Coldrick Date: Tue, 6 Jun 2023 13:54:43 +0000 (-0400) Subject: rgw_admin.cc: Handle pg_ver and source_zone explicitly X-Git-Tag: v19.0.0~759^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5e7c4a52ca84f31ab2aa4a1bde3af42c75998ead;p=ceph.git rgw_admin.cc: Handle pg_ver and source_zone explicitly At present, the pg_ver and source_zone attrs are handled as if they're strings, but are in fact unsigned integer types. This means that when dumped they yield invalid UTF-8 characters. As well as hiding the meaning of these attributes, this also means that we're not compliant with RFC 8259 for JSON, which specifies that externally visible JSON must be UTF-8 encoded [0]. [0]: https://rfc-editor.org/rfc/rfc8259#section-8.1 Signed-off-by: Tom Coldrick --- diff --git a/qa/workunits/rgw/test_rgw_d4n.py b/qa/workunits/rgw/test_rgw_d4n.py index c5ba5ec656881..85d0dc23907ee 100644 --- a/qa/workunits/rgw/test_rgw_d4n.py +++ b/qa/workunits/rgw/test_rgw_d4n.py @@ -127,11 +127,9 @@ def test_cache_methods(r, client, obj): attrs = json.loads(output.decode('latin-1')) assert((data.get(b'user.rgw.tail_tag')) == attrs.get('attrs').get('user.rgw.tail_tag').encode("latin-1") + b'\x00') - assert((data.get(b'user.rgw.pg_ver')) == attrs.get('attrs').get('user.rgw.pg_ver').encode("latin-1") + b'\x00\x00\x00\x00\x00\x00\x00') assert((data.get(b'user.rgw.idtag')) == attrs.get('tag').encode("latin-1") + b'\x00') assert((data.get(b'user.rgw.etag')) == attrs.get('etag').encode("latin-1")) assert((data.get(b'user.rgw.x-amz-content-sha256')) == attrs.get('attrs').get('user.rgw.x-amz-content-sha256').encode("latin-1") + b'\x00') - assert((data.get(b'user.rgw.source_zone')) == attrs.get('attrs').get('user.rgw.source_zone').encode("latin-1") + b'\x00\x00\x00\x00') assert((data.get(b'user.rgw.x-amz-date')) == attrs.get('attrs').get('user.rgw.x-amz-date').encode("latin-1") + b'\x00') tmp1 = '\x08\x06L\x01\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x06\x84\x00\x00\x00\n\nj\x00\x00\x00\x03\x00\x00\x00bkt+\x00\x00\x00' diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 59fb2d59df562..ffddfe63ee7ba 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -8293,6 +8293,10 @@ next: // TODO: decode torrent info for display as json? formatter->dump_string("torrent", ""); handled = true; + } else if (iter->first == RGW_ATTR_PG_VER) { + handled = decode_dump("pg_ver", bl, formatter.get()); + } else if (iter->first == RGW_ATTR_SOURCE_ZONE) { + handled = decode_dump("source_zone", bl, formatter.get()); } if (!handled)