]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
json_spirit: use utf8 intenally when parsing \uHHHH
authorTim Serong <tserong@suse.com>
Fri, 1 May 2015 15:59:53 +0000 (01:59 +1000)
committerNathan Cutler <ncutler@suse.cz>
Fri, 15 May 2015 10:24:45 +0000 (12:24 +0200)
commit678b3e6082729698ce3575ba70313dd8399b1aed
tree400b7d3e60ef7a0baab7f11f25387233a73aa7fa
parentb69fb89122d6f989152a29124cc7ed54b5e4d43b
json_spirit: use utf8 intenally when parsing \uHHHH

When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON.  json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.

This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.

Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane.  Still, that's rather a lot more characters than it could cope
with before ;)

(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)

Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 8add15b86e7aaef41397ab8fa9e77ee7957eb607)
src/json_spirit/json_spirit_reader_template.h
src/test/mon/osd-pool-create.sh