Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: base/json_reader.cc

Issue 4268: IsStringUTF8 unittest and enforcing UTF-8 in JSON deserialization (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/json_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json_reader.cc
===================================================================
--- base/json_reader.cc (revision 2506)
+++ base/json_reader.cc (working copy)
@@ -83,8 +83,11 @@
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();
« no previous file with comments | « no previous file | base/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698