PDA

View Full Version : [FIXED-1466] JSON decode throws an error under IE (but not under FF) on empty string



Pachat
21 Dec 2010, 8:58 AM
With json == "", Ext.util.JSON sends an error under IE (at least IE 6).
With the lines in bold added, it is Ok under IE and FF :


Ext.util.JSON = new (function(){
var useHasOwn = !!{}.hasOwnProperty,
isNative = function() {
var useNative = null;

return function() {
if (useNative === null) {
useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
}

return useNative;
};
}(),
pad = function(n) {
return n < 10 ? "0" + n : n;
},
doDecode = function(json){
if (json)
return eval("(" + json + ")");
else
return "";
},
.../...
Comment : For sure, json should not be empty, but that refers to the logic of the app.
Ext.util.JSON should prevent itself against such a situation.

meroy
29 Dec 2010, 11:13 AM
Thanks for the report. This has been fixed in SVN for the 3.3.x branch.

Pachat
29 Dec 2010, 11:48 AM
Thanks for the report. This has been fixed in SVN for the 3.3.x branch.Good news. Thanks.