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

Unified Diff: base/json/string_escape.cc

Issue 1512013: Improve JsonDoubleQuoteT to do script escapes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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/string_escape_unittest.cc » ('j') | net/base/dir_header.html » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/string_escape.cc
===================================================================
--- base/json/string_escape.cc (revision 43592)
+++ base/json/string_escape.cc (working copy)
@@ -58,9 +58,10 @@
for (typename STR::const_iterator it = str.begin(); it != str.end(); ++it) {
typename ToUnsigned<typename STR::value_type>::Unsigned c = *it;
if (!JsonSingleEscapeChar(c, dst)) {
- if (c < 32 || c > 126) {
- // Technically, we could also pass through c > 126 as UTF8, but this is
- // also optional. It would also be a pain to implement here.
+ if (c < 32 || c > 126 || c == 60 || c == 62) {
eroman 2010/04/06 01:43:12 nit: can you '<' instead of 60, and '>' instead of
+ // 1. Escaping <, > to prevent script execution.
+ // 2. Technically, we could also pass through c > 126 as UTF8, but this
+ // is also optional. It would also be a pain to implement here.
unsigned int as_uint = static_cast<unsigned int>(c);
StringAppendF(dst, "\\u%04X", as_uint);
} else {
« no previous file with comments | « no previous file | base/json/string_escape_unittest.cc » ('j') | net/base/dir_header.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698