From f6901ea7477d486f9bf3488fd7d63bff07e159f1 Mon Sep 17 00:00:00 2001 From: "sandholm@chromium.org" Date: Wed, 1 Jun 2011 14:55:55 +0000 Subject: [PATCH] Untank compilation and fix JSON parse bug introduced in r8147. Review URL: http://codereview.chromium.org/7020028 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8148 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/json-parser.cc | 13 +++++++------ src/json-parser.h | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/json-parser.cc b/src/json-parser.cc index 7e24310ab1..77a22b9f3d 100644 --- a/src/json-parser.cc +++ b/src/json-parser.cc @@ -167,6 +167,7 @@ Handle JsonParser::ParseJsonObject() { AdvanceSkipWhitespace(); if (c0_ != '}') { do { + if (c0_ != '"') return ReportUnexpectedCharacter(); Handle key = ParseJsonSymbol(); if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); AdvanceSkipWhitespace(); @@ -283,7 +284,7 @@ Handle JsonParser::ParseJsonNumber() { return isolate()->factory()->NewNumber(number_); } -Handle JsonParser::SlowScanJsonString() { +Handle JsonParser::SlowScanJsonString() { // The currently scanned ascii characters. Handle ascii(isolate()->factory()->NewSubString(source_, beg_pos_, @@ -312,7 +313,7 @@ Handle JsonParser::SlowScanJsonString() { } // Check for control character (0x00-0x1f) or unterminated string (<0). - if (c0_ < 0x20) return ReportUnexpectedCharacter(); + if (c0_ < 0x20) return Handle::null(); if (c0_ != '\\') { seq_two_byte->SeqTwoByteStringSet(count++, c0_); Advance(); @@ -345,7 +346,7 @@ Handle JsonParser::SlowScanJsonString() { Advance(); int digit = HexValue(c0_); if (digit < 0) { - return ReportUnexpectedCharacter(); + return Handle::null(); } value = value * 16 + digit; } @@ -353,7 +354,7 @@ Handle JsonParser::SlowScanJsonString() { break; } default: - return ReportUnexpectedCharacter(); + return Handle::null(); } Advance(); } @@ -381,14 +382,14 @@ Handle JsonParser::SlowScanJsonString() { template -Handle JsonParser::ScanJsonString() { +Handle JsonParser::ScanJsonString() { ASSERT_EQ('"', c0_); Advance(); beg_pos_ = position_; // Fast case for ascii only without escape characters. while (c0_ != '"') { // Check for control character (0x00-0x1f) or unterminated string (<0). - if (c0_ < 0x20) return ReportUnexpectedCharacter(); + if (c0_ < 0x20) return Handle::null(); if (c0_ != '\\' && c0_ < kMaxAsciiCharCode) { Advance(); } else { diff --git a/src/json-parser.h b/src/json-parser.h index 07f00f5058..2422c92c22 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -92,17 +92,17 @@ class JsonParser BASE_EMBEDDED { // literals. The string must only be double-quoted (not single-quoted), and // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. - Handle ParseJsonString() { + Handle ParseJsonString() { return ScanJsonString(); } - Handle ParseJsonSymbol() { + Handle ParseJsonSymbol() { return ScanJsonString(); } template - Handle ScanJsonString(); + Handle ScanJsonString(); // Slow version for unicode support, uses the first ascii_count characters, // as first part of a ConsString - Handle SlowScanJsonString(); + Handle SlowScanJsonString(); // A JSON number (production JSONNumber) is a subset of the valid JavaScript // decimal number literals.