mirror of
https://github.com/ceph/ceph
synced 2024-12-27 14:03:25 +00:00
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 <tcoldrick@bloomberg.com>
This commit is contained in:
parent
8392e7dff7
commit
5e7c4a52ca
@ -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'
|
||||
|
@ -8293,6 +8293,10 @@ next:
|
||||
// TODO: decode torrent info for display as json?
|
||||
formatter->dump_string("torrent", "<contains binary data>");
|
||||
handled = true;
|
||||
} else if (iter->first == RGW_ATTR_PG_VER) {
|
||||
handled = decode_dump<uint64_t>("pg_ver", bl, formatter.get());
|
||||
} else if (iter->first == RGW_ATTR_SOURCE_ZONE) {
|
||||
handled = decode_dump<uint32_t>("source_zone", bl, formatter.get());
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
|
Loading…
Reference in New Issue
Block a user