diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 16:43:49 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 16:43:49 +0000 |
commit | d36519b5068d92f4e71b8d6fd51eda2c42e54e38 (patch) | |
tree | 6aaf53187b1a36cc1d1f45c8f5ca994d55900650 /base/json_writer.cc | |
parent | c66cd7d3bfe3b572c7824db8c7d8d5c71cd21afd (diff) | |
download | chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.zip chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.tar.gz chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.tar.bz2 |
Add JSON-specific escaping, which has different rules from JS escaping.BUG=http://crbug.com/11431TEST=base_unittests.exe --gtest_filter=StringEscapeTest.Json*
Review URL: http://codereview.chromium.org/113606
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/json_writer.cc')
-rw-r--r-- | base/json_writer.cc | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/base/json_writer.cc b/base/json_writer.cc index aa66306..a95798e 100644 --- a/base/json_writer.cc +++ b/base/json_writer.cc @@ -92,16 +92,15 @@ void JSONWriter::BuildJSONString(const Value* const node, 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::BuildJSONString(const Value* const node, } 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) { |