Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed JSON command output when non-ASCII strings are present #4634

Closed
wants to merge 3 commits into from

Conversation

smithfarm
Copy link
Contributor

liewegas and others added 2 commits May 9, 2015 22:17
This is a simple safety check.  Since we default to true it is currently
opt-in.

Backport: giant, firefly
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 6b982e4)
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: ceph#7387

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 8add15b)
@smithfarm
Copy link
Contributor Author

I know backport PRs are supposed to contain a single commit only, but in this case 5369e10 (8add15 in master) depends on 47eecaf (6b982e in master), and the latter hasn't been backported yet and I couldn't find a tracker issue for it, either.

Fixes: ceph#11574
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 6b68b27)
@smithfarm
Copy link
Contributor Author

This last commit 010065e (6b68b2 in master) fixes a FTBFS introduced by the fix for http://tracker.ceph.com/issues/7387

There is a separate tracker issue http://tracker.ceph.com/issues/11574 open for it, but since it depends on this commit, it makes sense to combine.

@smithfarm
Copy link
Contributor Author

Looking at this in the light of morning I see that Sage's and Tim's commits are unrelated and really should be kept separate.

@smithfarm smithfarm closed this May 10, 2015
@smithfarm smithfarm deleted the wip-7387-firefly branch May 10, 2015 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants