Title: [104212] trunk
Revision
104212
Author
[email protected]
Date
2012-01-05 13:56:26 -0800 (Thu, 05 Jan 2012)

Log Message

Literal tab in JSONString fails
https://bugs.webkit.org/show_bug.cgi?id=71772

Reviewed by Oliver Hunt.

rfc4627 does not allow literal tab characters in JSON source.

Source/_javascript_Core: 

* runtime/LiteralParser.cpp:
(JSC::isSafeStringCharacter):
    - do not allow literal tab in StrictJSON mode.

LayoutTests: 

* fast/js/JSON-parse-expected.txt:
* fast/js/resources/JSON-parse.js:
(createTests.result):
    - Updated expected results.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104211 => 104212)


--- trunk/LayoutTests/ChangeLog	2012-01-05 21:56:24 UTC (rev 104211)
+++ trunk/LayoutTests/ChangeLog	2012-01-05 21:56:26 UTC (rev 104212)
@@ -1,3 +1,17 @@
+2012-01-05  Gavin Barraclough  <[email protected]>
+
+        Literal tab in JSONString fails
+        https://bugs.webkit.org/show_bug.cgi?id=71772
+
+        Reviewed by Oliver Hunt.
+
+        rfc4627 does not allow literal tab characters in JSON source.
+
+        * fast/js/JSON-parse-expected.txt:
+        * fast/js/resources/JSON-parse.js:
+        (createTests.result):
+            - Updated expected results.
+
 2012-01-05  Ojan Vafai  <[email protected]>
 
         IE quirk for percentage size on a table element doesn't work with orthogonal writing modes

Modified: trunk/LayoutTests/fast/js/JSON-parse-expected.txt (104211 => 104212)


--- trunk/LayoutTests/fast/js/JSON-parse-expected.txt	2012-01-05 21:56:24 UTC (rev 104211)
+++ trunk/LayoutTests/fast/js/JSON-parse-expected.txt	2012-01-05 21:56:26 UTC (rev 104212)
@@ -145,7 +145,8 @@
 function (jsonObject) {
         return jsonObject.parse('"a\tz"');
     }
-PASS JSON.stringify(tests[i](nativeJSON)) is JSON.stringify(tests[i](JSON))
+PASS tests[i](nativeJSON) threw exception SyntaxError: JSON Parse error: Unterminated string.
+json2.js did not throw for a test we expect to throw.
 function (jsonObject) {
         return jsonObject.parse('"a\\tz"');
     }

Modified: trunk/LayoutTests/fast/js/resources/JSON-parse.js (104211 => 104212)


--- trunk/LayoutTests/fast/js/resources/JSON-parse.js	2012-01-05 21:56:24 UTC (rev 104211)
+++ trunk/LayoutTests/fast/js/resources/JSON-parse.js	2012-01-05 21:56:26 UTC (rev 104212)
@@ -131,6 +131,7 @@
     result.push(function(jsonObject){
         return jsonObject.parse('"a\tz"');
     });
+    result[result.length - 1].throws = true; // rfc4627 does not allow literal tab characters in JSON source
     result.push(function(jsonObject){
         return jsonObject.parse('"a\\tz"');
     });

Modified: trunk/Source/_javascript_Core/ChangeLog (104211 => 104212)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-05 21:56:24 UTC (rev 104211)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-05 21:56:26 UTC (rev 104212)
@@ -1,5 +1,18 @@
 2012-01-05  Gavin Barraclough  <[email protected]>
 
+        Literal tab in JSONString fails
+        https://bugs.webkit.org/show_bug.cgi?id=71772
+
+        Reviewed by Oliver Hunt.
+
+        rfc4627 does not allow literal tab characters in JSON source.
+
+        * runtime/LiteralParser.cpp:
+        (JSC::isSafeStringCharacter):
+            - do not allow literal tab in StrictJSON mode.
+
+2012-01-05  Gavin Barraclough  <[email protected]>
+
         push/shift fifo may consume excessive memory
         https://bugs.webkit.org/show_bug.cgi?id=75610
 

Modified: trunk/Source/_javascript_Core/runtime/LiteralParser.cpp (104211 => 104212)


--- trunk/Source/_javascript_Core/runtime/LiteralParser.cpp	2012-01-05 21:56:24 UTC (rev 104211)
+++ trunk/Source/_javascript_Core/runtime/LiteralParser.cpp	2012-01-05 21:56:26 UTC (rev 104212)
@@ -330,12 +330,12 @@
 
 template <ParserMode mode, typename CharType, LChar terminator> static inline bool isSafeStringCharacter(LChar c)
 {
-    return (c >= ' ' && c != '\\' && c != terminator) || c == '\t';
+    return (c >= ' ' && c != '\\' && c != terminator) || (c == '\t' && mode != StrictJSON);
 }
 
 template <ParserMode mode, typename CharType, UChar terminator> static inline bool isSafeStringCharacter(UChar c)
 {
-    return (c >= ' ' && (mode == StrictJSON || c <= 0xff) && c != '\\' && c != terminator) || c == '\t';
+    return (c >= ' ' && (mode == StrictJSON || c <= 0xff) && c != '\\' && c != terminator) || (c == '\t' && mode != StrictJSON);
 }
 
 template <typename CharType>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to