Add UTF-8 check for JSON deserializer.
Add tests for IsStringUTF8
Make IsStringUTF8 accept std::string/std::wstring rather than char*/wchar_t*
Review URL: http://codereview.chromium.org/4268
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2610 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: c9ec45429c64884c35f83b74131c0e3ae5b2bbe9
diff --git a/base/json_reader_unittest.cc b/base/json_reader_unittest.cc
index 6c60a07..c2d6a42 100644
--- a/base/json_reader_unittest.cc
+++ b/base/json_reader_unittest.cc
@@ -481,6 +481,13 @@
ASSERT_EQ(L"\x7f51\x9875", str_val);
delete root;
+ // Test invalid utf8 encoded input
+ root = NULL;
+ ASSERT_FALSE(JSONReader::JsonToValue("\"345\xb0\xa1\xb0\xa2\"", &root,
+ false, false));
+ ASSERT_FALSE(JSONReader::JsonToValue("\"123\xc0\x81\"", &root,
+ false, false));
+
// Test invalid root objects.
root = NULL;
ASSERT_FALSE(JSONReader::Read("null", &root, false));