Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12615 closed defect (fixed)

[patch][ccla] The dojo.toJson fails when the object being serialized contains nested arrays.

Reported by: Patrick Ruzand Owned by: Kris Zyp
Priority: high Milestone: 1.7
Component: Core Version: 1.6.0
Keywords: 1.7-mobile Cc: [email protected]
Blocked By: Blocking:

Description

The dojo.toJson function on Firefox (and maybe other browsers) fails when the object being serialized contains nested arrays. The reason is at line 100 in dojo/json.js: the 'itl' variable is never declared as a local variable, so it will be created in the global context. If the function is called recursively (which happens with nested arrays), then obviously things will go wrong since the global variable will be modified by the recursive call.

The bug occurs only when the dojo.toJson is set to the stringify function defined in dojo/json.js (for example on Firefox).

The fix is simply to add a 'var itl;' statement before the loop. Attached patch + test Patch by Eric Durocher (IBM, CCLA)

Attachments (2)

12615.patch (396 bytes) - added by Patrick Ruzand 10 years ago.
patch file
jsonbug.html (550 bytes) - added by Patrick Ruzand 10 years ago.
test

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by Patrick Ruzand

Attachment: 12615.patch added

patch file

Changed 10 years ago by Patrick Ruzand

Attachment: jsonbug.html added

test

comment:1 Changed 10 years ago by bill

Owner: set to Kris Zyp

comment:2 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [24216]) Fix missing var for itl, fixes #12615

comment:3 Changed 10 years ago by bill

Milestone: tbd1.7

comment:4 Changed 10 years ago by liucougar

(In [24226]) refs #12615: added test coverage for toJson nested arrays

Note: See TracTickets for help on using tickets.