Skip to content

Commit

Permalink
Lift \u0000 constraint in JSON parsing for backward compatibility
Browse files Browse the repository at this point in the history
Summary:
This is to lift a unicode constraint to allow \u0000 (null) in the JSON string,
for backward data compatibility.

Test Plan: Jenkins

Reviewers: pengt

Reviewed By: pengt

Subscribers: webscalesql-eng

Differential Revision: https://reviews.facebook.net/D54543
  • Loading branch information
tianx authored and Herman Lee committed Feb 22, 2016
1 parent 76ef39e commit b7a9201
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fbson/FbsonJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class FbsonJsonParserT {
For DC00 to DFFF, it should be low surrogates for UTF16.
So if it display in the high bits, it's invalid.
*/
if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc==0){
if (uc >= 0xDC00 && uc <= 0xDFFF){
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/json/r/type_document_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ insert into t4 values(3, "{\"\\b\\f\\n\\r\\t\":\"123\\t\\r\\n\\f\\bABC\"}", "esc
insert into t4 values(4, "{\"Status\":\"\\u675f\\u5e26\\u7ed3\\u53d1\\u523b\\u5f55\\u673a\\u5076\\u5c14\\u4e94\\u798f\\u805a\\u54e6\"}", "escape of Unicode");
insert into t4 values(5, "{\"\\u0009\":\"\\u000d\\u000a\"}", "escape of Unicode for control char");
insert into t4 values(6, "{\"Control\":\"\\u0002\"}", "escape of Unicode for control char");
insert into t4 values(7, "{\"NULL\":\"\\u0000\"}", "Unicode for NULL");
insert into t4 values(8, '{"NULL":"\\u0000"}', "Unicode for NULL");
select * from t4;
i a s
1 {"Name":"Json\tXia"} escape in value
Expand All @@ -222,6 +224,8 @@ i a s
4 {"Status":"束带结发刻录机偶尔五福聚哦"} escape of Unicode
5 {"\t":"\r\n"} escape of Unicode for control char
6 {"Control":"\u0002"} escape of Unicode for control char
7 {"NULL":""} Unicode for NULL
8 {"NULL":""} Unicode for NULL
create table t5 (i int(8), a document, s text(255)) engine = innodb;
insert into t5 values(1, "{\"BAD\":\"123\\u0xDFFE\"}", "Bad Unicode");
ERROR HY000: Invalid document value: '{"BAD":"123\u0xDFFE"}', pos 14, error 'Invalid string value'
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/json/t/type_document_innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ insert into t4 values(3, "{\"\\b\\f\\n\\r\\t\":\"123\\t\\r\\n\\f\\bABC\"}", "esc
insert into t4 values(4, "{\"Status\":\"\\u675f\\u5e26\\u7ed3\\u53d1\\u523b\\u5f55\\u673a\\u5076\\u5c14\\u4e94\\u798f\\u805a\\u54e6\"}", "escape of Unicode");
insert into t4 values(5, "{\"\\u0009\":\"\\u000d\\u000a\"}", "escape of Unicode for control char");
insert into t4 values(6, "{\"Control\":\"\\u0002\"}", "escape of Unicode for control char");
insert into t4 values(7, "{\"NULL\":\"\\u0000\"}", "Unicode for NULL");
insert into t4 values(8, '{"NULL":"\\u0000"}', "Unicode for NULL");
select * from t4;

# Test FBSon with wrong escape
Expand Down

0 comments on commit b7a9201

Please sign in to comment.