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

Unified Diff: base/string_escape.h

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 | « base/json_writer.cc ('k') | base/string_escape.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_escape.h
===================================================================
--- base/string_escape.h (revision 16481)
+++ base/string_escape.h (working copy)
@@ -7,29 +7,26 @@
#ifndef BASE_STRING_ESCAPE_H__
#define BASE_STRING_ESCAPE_H__
+#include <string>
+
#include "base/string16.h"
namespace string_escape {
-// Escape |str| appropriately for a javascript string litereal, _appending_ the
-// result to |dst|. This will create standard escape sequences (\b, \n),
-// hex escape sequences (\x00), and unicode escape sequences (\uXXXX).
+// Escape |str| appropriately for a JSON string litereal, _appending_ the
+// result to |dst|. This will create unicode escape sequences (\uXXXX).
// If |put_in_quotes| is true, the result will be surrounded in double quotes.
// The outputted literal, when interpreted by the browser, should result in a
// javascript string that is identical and the same length as the input |str|.
-void JavascriptDoubleQuote(const string16& str,
- bool put_in_quotes,
- std::string* dst);
+void JsonDoubleQuote(const std::string& str,
+ bool put_in_quotes,
+ std::string* dst);
-// Similar to the wide version, but for narrow strings. It will not use
-// \uXXXX unicode escape sequences. It will pass non-7bit characters directly
-// into the string unencoded, allowing the browser to interpret the encoding.
-// The outputted literal, when interpreted by the browser, could result in a
-// javascript string of a different length than the input |str|.
-void JavascriptDoubleQuote(const std::string& str,
- bool put_in_quotes,
- std::string* dst);
+void JsonDoubleQuote(const string16& str,
+ bool put_in_quotes,
+ std::string* dst);
+
} // namespace string_escape
#endif // BASE_STRING_ESCAPE_H__
« no previous file with comments | « base/json_writer.cc ('k') | base/string_escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698