Opened 8 years ago
Closed 8 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)
Change History (8)
comment:1 Changed 8 years ago by
Changed 8 years ago by
Attachment: | allow-empty-strings-in-strict-json.patch added |
---|
[patch][ccla] allow-empty-strings-in-strict-json Andy Balaam (IBM, CCLA)
comment:2 Changed 8 years ago by
Component: | General → Core |
---|---|
Owner: | set to Kris Zyp |
Status: | new → assigned |
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 8 years ago by
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:5 Changed 8 years ago by
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 8 years ago by
Keywords: | IE6 IE7 added |
---|---|
Milestone: | tbd → 1.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.
Note: See
TracTickets for help on using
tickets.
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().