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

Side by Side Diff: base/json/json_parser.cc

Issue 2823023002: Do not silently drop \u0000 in base::JSONReader (Closed)
Patch Set: Created 3 years, 8 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_reader_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"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 CBU8_APPEND_UNSAFE(code_unit8, offset, code_point); 642 CBU8_APPEND_UNSAFE(code_unit8, offset, code_point);
643 } else { 643 } else {
644 // Not a surrogate. 644 // Not a surrogate.
645 DCHECK(CBU16_IS_SINGLE(code_unit16_high)); 645 DCHECK(CBU16_IS_SINGLE(code_unit16_high));
646 if (!IsValidCharacter(code_unit16_high)) 646 if (!IsValidCharacter(code_unit16_high))
647 return false; 647 return false;
648 648
649 CBU8_APPEND_UNSAFE(code_unit8, offset, code_unit16_high); 649 CBU8_APPEND_UNSAFE(code_unit8, offset, code_unit16_high);
650 } 650 }
651 651
652 dest_string->append(code_unit8); 652 dest_string->append(code_unit8, offset);
653 return true; 653 return true;
654 } 654 }
655 655
656 void JSONParser::DecodeUTF8(const int32_t& point, StringBuilder* dest) { 656 void JSONParser::DecodeUTF8(const int32_t& point, StringBuilder* dest) {
657 DCHECK(IsValidCharacter(point)); 657 DCHECK(IsValidCharacter(point));
658 658
659 // Anything outside of the basic ASCII plane will need to be decoded from 659 // Anything outside of the basic ASCII plane will need to be decoded from
660 // int32_t to a multi-byte sequence. 660 // int32_t to a multi-byte sequence.
661 if (point < kExtendedASCIIStart) { 661 if (point < kExtendedASCIIStart) {
662 dest->Append(static_cast<char>(point)); 662 dest->Append(static_cast<char>(point));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 const std::string& description) { 830 const std::string& description) {
831 if (line || column) { 831 if (line || column) {
832 return StringPrintf("Line: %i, column: %i, %s", 832 return StringPrintf("Line: %i, column: %i, %s",
833 line, column, description.c_str()); 833 line, column, description.c_str());
834 } 834 }
835 return description; 835 return description;
836 } 836 }
837 837
838 } // namespace internal 838 } // namespace internal
839 } // namespace base 839 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698