mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-07 18:39:23 +03:00
Avoid using eval when JSON.parse is available.
This commit is contained in:
parent
1c17374de1
commit
4bb80067f7
@ -2176,6 +2176,24 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
return $.parseXml( string );
|
return $.parseXml( string );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a JSON string into a Javascript object.
|
||||||
|
* @function
|
||||||
|
* @param {String} string
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
parseJSON: function(string) {
|
||||||
|
if (window.JSON && window.JSON.parse) {
|
||||||
|
$.parseJSON = window.JSON.parse;
|
||||||
|
} else {
|
||||||
|
// Should only be used by IE8 in non standards mode
|
||||||
|
$.parseJSON = function(string) {
|
||||||
|
/*jshint evil:true*/
|
||||||
|
return eval('(' + string + ')');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return $.parseJSON(string);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports whether the image format is supported for tiling in this
|
* Reports whether the image format is supported for tiling in this
|
||||||
|
@ -613,8 +613,7 @@ function processResponse( xhr ){
|
|||||||
data = xhr.responseText;
|
data = xhr.responseText;
|
||||||
}
|
}
|
||||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||||
/*jshint evil:true*/
|
data = $.parseJSON(responseText);
|
||||||
data = eval( '('+responseText+')' );
|
|
||||||
}else{
|
}else{
|
||||||
data = responseText;
|
data = responseText;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user