mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 23:21:42 +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 );
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -613,8 +613,7 @@ function processResponse( xhr ){
|
||||
data = xhr.responseText;
|
||||
}
|
||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||
/*jshint evil:true*/
|
||||
data = eval( '('+responseText+')' );
|
||||
data = $.parseJSON(responseText);
|
||||
}else{
|
||||
data = responseText;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user