Opened 6 years ago

Closed 6 years ago

#16255 closed defect (fixed)

[patch] [ccla] "Strict" JSON parsing in Rhino, IE6-7 can't handle empty strings

Reported by: andybalaam Owned by: Kris Zyp
Priority: undecided Milestone: 1.9
Component: Core Version: 1.8.1
Keywords: IE6, IE7 Cc:
Blocked By: Blocking:

Description

When I add this simple test to the tests/json.js test, it fails on Rhino:

diff --git a/tests/json.js b/tests/json.js
index eb7c5f8..192b487 100644
--- a/tests/json.js
+++ b/tests/json.js
@@ -54,7 +54,9 @@ define(["../main", "doh/main", "../json"], function(dojo, doh, JSON){
 
                },
                /*Apparently Firefox doesn't pass the key to the toJSON method*/
-               function serializeToJSON(t){ t.is('{"foo":{"name":"value"}}', JSON.stringify({foo:{toJSON:function(key){return {name:"value"}; }}})); }
+               function serializeToJSON(t){ t.is('{"foo":{"name":"value"}}', JSON.stringify({foo:{toJSON:function(key){return {name:"value"}; }}})); },
+               /*Strict parsing was failing when an empty string was used*/
+               function emptyString(t){ t.is("", JSON.parse('{"foo":""}', true).foo); }
        ]);
 
 var smallDataSet = {

with an error like this:

$ java -jar util/shrinksafe/js.jar dojo/dojo.js baseUrl=file://$PWD/dojo load=doh test=dojo/tests/json

------------------------------------------------------------
The Dojo Unit Test Harness, $Rev: 23869 $
Copyright (c) 2011, The Dojo Foundation, All Rights Reserved
loading test dojo/tests/json
------------------------------------------------------------ 

37 tests to run in 2 groups
------------------------------------------------------------
GROUP "tests.json" has 31 tests to run
	Error: Invalid characters in JSON
	ERROR IN:
		 (function emptyString(t) {t.is("", JSON.parse("{\"foo\":\"\"}", true).foo);})
------------------------------------------------------------
GROUP "tests.json.performance" has 6 tests to run
------------------------------------------------------------
| TEST SUMMARY:
------------------------------------------------------------
	 37 tests in 2 groups
	 1 errors
	 0 failures

Attachments (1)

allow-empty-strings-in-strict-json.patch (761 bytes) - added by andybalaam 6 years ago.
[patch][ccla] allow-empty-strings-in-strict-json Andy Balaam (IBM, CCLA)

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by andybalaam

Note that due to ticket http://bugs.dojotoolkit.org/ticket/16254 I was unable to run this test at all with Rhino until I commented out the existing test serializeCircular().

Changed 6 years ago by andybalaam

[patch][ccla] allow-empty-strings-in-strict-json Andy Balaam (IBM, CCLA)

comment:2 Changed 6 years ago by bill

Component: GeneralCore
Owner: set to Kris Zyp
Status: newassigned
Summary: "Strict" JSON parsing in Rhino can't handle empty strings[patch] [ccla] "Strict" JSON parsing in Rhino can't handle empty strings

I can't wrap my head around that regex, but anyway Kris should check it in; it's his code (from #8111).

comment:3 Changed 6 years ago by bill

PS: I guess it doesn't have anything specifically to do w/Rhino, but fails on any system where JSON.parse isn't available?

comment:4 Changed 6 years ago by andybalaam

Hi Bill, yes - this fails on IE7 as well.

comment:5 Changed 6 years ago by bill

Summary: [patch] [ccla] "Strict" JSON parsing in Rhino can't handle empty strings[patch] [ccla] "Strict" JSON parsing in Rhino, IE6-7 can't handle empty strings

comment:6 Changed 6 years ago by dylan

Keywords: IE6 IE7 added
Milestone: tbd1.9

Kris, can you review and get this into 1.9 please? Since this is likely the last IE 6/7 release, it would be nice to stabilize wherever possible.

comment:7 Changed 6 years ago by Kris Zyp

Resolution: fixed
Status: assignedclosed

In [30704]:

Allow empty strings in strict JSON parsing, fixes #16255 !strict

Note: See TracTickets for help on using tickets.