Chromium Code Reviews| 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 { |