Opened 8 years ago

Closed 8 years ago

Last modified 8 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: pruzand@…
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 8 years ago.
patch file
jsonbug.html (550 bytes) - added by Patrick Ruzand 8 years ago.
test

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by Patrick Ruzand

Attachment: 12615.patch added

patch file

Changed 8 years ago by Patrick Ruzand

Attachment: jsonbug.html added

test

comment:1 Changed 8 years ago by bill

Owner: set to Kris Zyp

comment:2 Changed 8 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

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

comment:3 Changed 8 years ago by bill

Milestone: tbd1.7

comment:4 Changed 8 years ago by liucougar

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

Note: See TracTickets for help on using tickets.