diff options
author | Daniel Kraft <d@domob.eu> | 2015-06-10 14:57:57 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2015-06-11 12:09:05 +0200 |
commit | 0cc7b2352e749a7863d7b5ed680e3fb5f04f9511 (patch) | |
tree | 613e4d563b3f7f7590b45621da797536d77c04c3 /src/test/univalue_tests.cpp | |
parent | 51870fc1512157de3b3b9640a9332afb7e2c3aa4 (diff) |
Fix univalue handling of \u0000 characters.
Univalue's parsing of \u escape sequences did not handle NUL characters
correctly. They were, effectively, dropped. The extended test-case
fails with the old code, and is fixed with this patch.
Diffstat (limited to 'src/test/univalue_tests.cpp')
-rw-r--r-- | src/test/univalue_tests.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp index de84faca23..2c1d303f66 100644 --- a/src/test/univalue_tests.cpp +++ b/src/test/univalue_tests.cpp @@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(univalue_object) } static const char *json1 = -"[1.10000000,{\"key1\":\"str\",\"key2\":800,\"key3\":{\"name\":\"martian\"}}]"; +"[1.10000000,{\"key1\":\"str\\u0000\",\"key2\":800,\"key3\":{\"name\":\"martian\"}}]"; BOOST_AUTO_TEST_CASE(univalue_readwrite) { @@ -306,7 +306,9 @@ BOOST_AUTO_TEST_CASE(univalue_readwrite) BOOST_CHECK_EQUAL(obj.size(), 3); BOOST_CHECK(obj["key1"].isStr()); - BOOST_CHECK_EQUAL(obj["key1"].getValStr(), "str"); + std::string correctValue("str"); + correctValue.push_back('\0'); + BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue); BOOST_CHECK(obj["key2"].isNum()); BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800"); BOOST_CHECK(obj["key3"].isObject()); |