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

Side by Side Diff: components/safe_json/json_sanitizer_unittest.cc

Issue 2570113002: Increase the depth limit of JSONParser and IPC serialization from 100 to 200. (Closed)
Patch Set: added comment Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/safe_json/json_sanitizer.h" 5 #include "components/safe_json/json_sanitizer.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // JSON syntax errors: 126 // JSON syntax errors:
127 CheckError(""); 127 CheckError("");
128 CheckError("["); 128 CheckError("[");
129 CheckError("null"); 129 CheckError("null");
130 130
131 // Unterminated array. 131 // Unterminated array.
132 CheckError("[1,2,3,]"); 132 CheckError("[1,2,3,]");
133 } 133 }
134 134
135 TEST_F(JsonSanitizerTest, Nesting) { 135 TEST_F(JsonSanitizerTest, Nesting) {
136 // 99 nested arrays are fine. 136 // 199 nested arrays are fine.
137 std::string nested(99u, '['); 137 std::string nested(199u, '[');
138 nested.append(99u, ']'); 138 nested.append(199u, ']');
139 CheckSuccess(nested); 139 CheckSuccess(nested);
140 140
141 // 100 nested arrays is too much. 141 // 200 nested arrays is too much.
142 CheckError(std::string(100u, '[') + std::string(100u, ']')); 142 CheckError(std::string(200u, '[') + std::string(200u, ']'));
143 } 143 }
144 144
145 TEST_F(JsonSanitizerTest, Unicode) { 145 TEST_F(JsonSanitizerTest, Unicode) {
146 // Non-ASCII characters encoded either directly as UTF-8 or escaped as UTF-16: 146 // Non-ASCII characters encoded either directly as UTF-8 or escaped as UTF-16:
147 CheckSuccess("[\"☃\"]"); 147 CheckSuccess("[\"☃\"]");
148 CheckSuccess("[\"\\u2603\"]"); 148 CheckSuccess("[\"\\u2603\"]");
149 CheckSuccess("[\"😃\"]"); 149 CheckSuccess("[\"😃\"]");
150 CheckSuccess("[\"\\ud83d\\ude03\"]"); 150 CheckSuccess("[\"\\ud83d\\ude03\"]");
151 151
152 // Malformed UTF-8: 152 // Malformed UTF-8:
(...skipping 25 matching lines...) Expand all
178 // A low surrogate followed by a high surrogate. 178 // A low surrogate followed by a high surrogate.
179 CheckError("[\"\\ude03\\ud83d\"]"); 179 CheckError("[\"\\ude03\\ud83d\"]");
180 180
181 // Valid escaped UTF-16 that encodes non-characters: 181 // Valid escaped UTF-16 that encodes non-characters:
182 CheckError("[\"\\ufdd0\"]"); 182 CheckError("[\"\\ufdd0\"]");
183 CheckError("[\"\\ufffe\"]"); 183 CheckError("[\"\\ufffe\"]");
184 CheckError("[\"\\ud83f\\udffe\"]"); 184 CheckError("[\"\\ud83f\\udffe\"]");
185 } 185 }
186 186
187 } // namespace safe_json 187 } // namespace safe_json
OLDNEW
« no previous file with comments | « components/safe_json/android/java/src/org/chromium/components/safejson/JsonSanitizer.java ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698