]> git-server-git.apps.pok.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>
Sun, 10 May 2015 09:40:08 +0000 (11:40 +0200)
commit84b00f189554fc37413c990ac4011079bb5cdb60
tree50527aa76a95259e476b2254e654d06483089516
parentfcd0ea3383582e7a1dc8091e7a48e1d4bbaa76ee
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)

Conflicts:
src/test/mon/osd-pool-create.sh

        Changed $CEPH_MON to 127.0.0.1 -- the CEPH_MON was introduced after
        firefly to allow tests to run in parallel. Back in firefly all tests
        use the same port because 127.0.0.1 was hardcoded. We can't
        conveniently backport all that's necessary for tests to run in
        parallel, therefore we keep the 127.0.0.1 hardcoded.
src/json_spirit/json_spirit_reader_template.h
src/test/mon/osd-pool-create.sh