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

Side by Side Diff: base/json/json_parser.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
« no previous file with comments | « no previous file | base/json/json_parser_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/json/json_parser.h" 5 #include "base/json/json_parser.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversion_utils.h" 17 #include "base/strings/utf_string_conversion_utils.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/third_party/icu/icu_utf.h" 19 #include "base/third_party/icu/icu_utf.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 21
22 namespace base { 22 namespace base {
23 namespace internal { 23 namespace internal {
24 24
25 namespace { 25 namespace {
26 26
27 const int kStackMaxDepth = 100; 27 // Chosen to support 99.9% of documents found in the wild late 2016.
28 // http://crbug.com/673263
29 const int kStackMaxDepth = 200;
28 30
29 const int32_t kExtendedASCIIStart = 0x80; 31 const int32_t kExtendedASCIIStart = 0x80;
30 32
31 // DictionaryHiddenRootValue and ListHiddenRootValue are used in conjunction 33 // DictionaryHiddenRootValue and ListHiddenRootValue are used in conjunction
32 // with JSONStringValue as an optimization for reducing the number of string 34 // with JSONStringValue as an optimization for reducing the number of string
33 // copies. When this optimization is active, the parser uses a hidden root to 35 // copies. When this optimization is active, the parser uses a hidden root to
34 // keep the original JSON input string live and creates JSONStringValue children 36 // keep the original JSON input string live and creates JSONStringValue children
35 // holding StringPiece references to the input string, avoiding about 2/3rds of 37 // holding StringPiece references to the input string, avoiding about 2/3rds of
36 // string memory copies. The real root value is Swap()ed into the new instance. 38 // string memory copies. The real root value is Swap()ed into the new instance.
37 class DictionaryHiddenRootValue : public DictionaryValue { 39 class DictionaryHiddenRootValue : public DictionaryValue {
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 const std::string& description) { 991 const std::string& description) {
990 if (line || column) { 992 if (line || column) {
991 return StringPrintf("Line: %i, column: %i, %s", 993 return StringPrintf("Line: %i, column: %i, %s",
992 line, column, description.c_str()); 994 line, column, description.c_str());
993 } 995 }
994 return description; 996 return description;
995 } 997 }
996 998
997 } // namespace internal 999 } // namespace internal
998 } // namespace base 1000 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/json/json_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698