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

Unified Diff: base/json_writer.cc

Issue 113606: Add JSON-specific escaping, which has different rules from JS escaping. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/string_escape.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json_writer.cc
===================================================================
--- base/json_writer.cc (revision 16481)
+++ base/json_writer.cc (working copy)
@@ -92,16 +92,15 @@
case Value::TYPE_STRING:
{
+ std::string value;
+ bool result = node->GetAsString(&value);
+ DCHECK(result);
if (escape) {
- std::wstring value;
- bool result = node->GetAsString(&value);
- DCHECK(result);
- AppendQuotedString(value);
+ string_escape::JsonDoubleQuote(UTF8ToUTF16(value),
+ true,
+ json_string_);
} else {
- std::string value;
- bool result = node->GetAsString(&value);
- DCHECK(result);
- string_escape::JavascriptDoubleQuote(value, true, json_string_);
+ string_escape::JsonDoubleQuote(value, true, json_string_);
}
break;
}
@@ -182,9 +181,9 @@
}
void JSONWriter::AppendQuotedString(const std::wstring& str) {
- string_escape::JavascriptDoubleQuote(WideToUTF16Hack(str),
- true,
- json_string_);
+ string_escape::JsonDoubleQuote(WideToUTF16Hack(str),
+ true,
+ json_string_);
}
void JSONWriter::IndentLine(int depth) {
« no previous file with comments | « no previous file | base/string_escape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698