Revert "The expected key is a valid identifier, which is already free of \\, <0x20...
authorverwaest <verwaest@chromium.org>
Mon, 23 Feb 2015 17:57:04 +0000 (09:57 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 23 Feb 2015 17:57:17 +0000 (17:57 +0000)
The optimization is invalid as indicated by the test.

BUG=
TBR=yangguo@chromium.org

Review URL: https://codereview.chromium.org/950873003

Cr-Commit-Position: refs/heads/master@{#26799}

src/json-parser.h
test/mjsunit/json2.js

index 9a22738..4d45138 100644 (file)
@@ -108,8 +108,9 @@ class JsonParser BASE_EMBEDDED {
         const uint8_t* expected_chars = content.ToOneByteVector().start();
         for (int i = 0; i < length; i++) {
           uint8_t c0 = input_chars[i];
-          // The expected string has to be free of \, " and characters < 0x20.
-          if (c0 != expected_chars[i]) return false;
+          if (c0 != expected_chars[i] || c0 == '"' || c0 < 0x20 || c0 == '\\') {
+            return false;
+          }
         }
         if (input_chars[length] == '"') {
           position_ = position_ + length + 1;
index f048f05..f68c76c 100644 (file)
@@ -183,3 +183,8 @@ try {
   externalizeString(str, true);
 } catch (e) { }
 TestStringify("\"external\"", str, null, 0);
+
+var o = {};
+o.somespecialproperty = 10;
+o["\x19"] = 10;
+assertThrows("JSON.parse('{\"somespecialproperty\":100, \"\x19\":10}')");