Chromium Code Reviews| Index: base/json/json_parser.cc |
| diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc |
| index 9ce6a2c1e73fa7105402ee84580eb564bcddd700..ca0015ceb66efdffde7bae2de042628a8144867a 100644 |
| --- a/base/json/json_parser.cc |
| +++ b/base/json/json_parser.cc |
| @@ -626,11 +626,19 @@ bool JSONParser::ConsumeStringRaw(StringBuilder* out) { |
| int32_t next_char = 0; |
| while (CanConsume(1)) { |
| + const int start_index = index_; |
|
sky
2016/11/03 19:14:14
It may be possible to backtrack for the first vali
|
| pos_ = start_pos_ + index_; // CBU8_NEXT is postcrement. |
| CBU8_NEXT(start_pos_, index_, length, next_char); |
| if (next_char < 0 || !IsValidCharacter(next_char)) { |
| - ReportError(JSONReader::JSON_UNSUPPORTED_ENCODING, 1); |
| - return false; |
| + if ((options_ & JSON_ALLOW_NON_UTF_STRINGS) == 0) { |
| + ReportError(JSONReader::JSON_UNSUPPORTED_ENCODING, 1); |
| + return false; |
| + } |
| + string.Convert(); |
| + std::string invalid_string(index_ - start_index, 0); |
| + memcpy(&invalid_string.front(), pos_, index_ - start_index); |
|
brettw
2016/11/04 23:17:13
Personally, I would prefer substituting it with th
sky
2016/11/08 01:02:20
Done.
|
| + string.AppendString(invalid_string); |
| + continue; |
| } |
| if (next_char == '"') { |