diff options
author | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 21:42:00 +0000 |
---|---|---|
committer | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 21:42:00 +0000 |
commit | c9ec45429c64884c35f83b74131c0e3ae5b2bbe9 (patch) | |
tree | 39007373603b8e75f53fa5e4d0c1586b1a3a56b5 /base/json_reader.cc | |
parent | 7e2fa03804bef4bff9c5bb941f2edf09b6d234c0 (diff) | |
download | chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.zip chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.tar.gz chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.tar.bz2 |
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
Diffstat (limited to 'base/json_reader.cc')
-rw-r--r-- | base/json_reader.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/base/json_reader.cc b/base/json_reader.cc index 72ce364..8d0cab4 100644 --- a/base/json_reader.cc +++ b/base/json_reader.cc @@ -83,8 +83,11 @@ bool JSONReader::JsonToValue(const std::string& json, Value** root, bool check_root, bool allow_trailing_comma) { - // Assume input is UTF8. The conversion from UTF8 to wstring removes null - // bytes for us (a good thing). + // The input must be in UTF-8. + if (!IsStringUTF8(json.c_str())) + return false; + // The conversion from UTF8 to wstring removes null bytes for us + // (a good thing). std::wstring json_wide(UTF8ToWide(json)); const wchar_t* json_cstr = json_wide.c_str(); |