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

Side by Side Diff: base/string_escape.cc

Issue 5628: Fixes bug where JSON reader errored on reading vertical tabs (\v). The... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json_reader_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/string_escape.h" 5 #include "base/string_escape.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 10
11 namespace string_escape { 11 namespace string_escape {
12 12
13 // Try to escape |c| as a "SingleEscapeCharacter" (\n, etc). If successful, 13 // Try to escape |c| as a "SingleEscapeCharacter" (\n, etc). If successful,
14 // returns true and appends the escape sequence to |dst|. 14 // returns true and appends the escape sequence to |dst|.
15 template<typename CHAR> 15 template<typename CHAR>
16 static bool JavascriptSingleEscapeChar(const CHAR c, std::string* dst) { 16 static bool JavascriptSingleEscapeChar(const CHAR c, std::string* dst) {
17 // WARNING: if you add a new case here, you need to update the reader as well.
17 switch (c) { 18 switch (c) {
18 case '\b': 19 case '\b':
19 dst->append("\\b"); 20 dst->append("\\b");
20 break; 21 break;
21 case '\f': 22 case '\f':
22 dst->append("\\f"); 23 dst->append("\\f");
23 break; 24 break;
24 case '\n': 25 case '\n':
25 dst->append("\\n"); 26 dst->append("\\n");
26 break; 27 break;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 } 91 }
91 } 92 }
92 93
93 if (put_in_quotes) 94 if (put_in_quotes)
94 dst->push_back('"'); 95 dst->push_back('"');
95 } 96 }
96 97
97 } // namespace string_escape 98 } // namespace string_escape
98 99
OLDNEW
« no previous file with comments | « base/json_reader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698