| OLD | NEW |
| 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 // Allowed esape sequences: | 663 // Allowed esape sequences: |
| 664 case 'x': { // UTF-8 sequence. | 664 case 'x': { // UTF-8 sequence. |
| 665 // UTF-8 \x escape sequences are not allowed in the spec, but they | 665 // UTF-8 \x escape sequences are not allowed in the spec, but they |
| 666 // are supported here for backwards-compatiblity with the old parser. | 666 // are supported here for backwards-compatiblity with the old parser. |
| 667 if (!CanConsume(2)) { | 667 if (!CanConsume(2)) { |
| 668 ReportError(JSONReader::JSON_INVALID_ESCAPE, 1); | 668 ReportError(JSONReader::JSON_INVALID_ESCAPE, 1); |
| 669 return false; | 669 return false; |
| 670 } | 670 } |
| 671 | 671 |
| 672 int hex_digit = 0; | 672 int hex_digit = 0; |
| 673 if (!HexStringToInt(StringPiece(NextChar(), 2), &hex_digit)) { | 673 if (!HexStringToInt(StringPiece(NextChar(), 2), &hex_digit) || |
| 674 !IsValidCharacter(hex_digit)) { |
| 674 ReportError(JSONReader::JSON_INVALID_ESCAPE, -1); | 675 ReportError(JSONReader::JSON_INVALID_ESCAPE, -1); |
| 675 return false; | 676 return false; |
| 676 } | 677 } |
| 677 NextChar(); | 678 NextChar(); |
| 678 | 679 |
| 679 if (hex_digit < kExtendedASCIIStart) | 680 if (hex_digit < kExtendedASCIIStart) |
| 680 string.Append(static_cast<char>(hex_digit)); | 681 string.Append(static_cast<char>(hex_digit)); |
| 681 else | 682 else |
| 682 DecodeUTF8(hex_digit, &string); | 683 DecodeUTF8(hex_digit, &string); |
| 683 break; | 684 break; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 const std::string& description) { | 981 const std::string& description) { |
| 981 if (line || column) { | 982 if (line || column) { |
| 982 return StringPrintf("Line: %i, column: %i, %s", | 983 return StringPrintf("Line: %i, column: %i, %s", |
| 983 line, column, description.c_str()); | 984 line, column, description.c_str()); |
| 984 } | 985 } |
| 985 return description; | 986 return description; |
| 986 } | 987 } |
| 987 | 988 |
| 988 } // namespace internal | 989 } // namespace internal |
| 989 } // namespace base | 990 } // namespace base |
| OLD | NEW |