diff --git a/src/viewer.js b/src/viewer.js index 02556bcf..92f0bb80 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2121,9 +2121,11 @@ function getTileSourceImplementation( viewer, tileSource, imgOptions, successCal //allow plain xml strings or json strings to be parsed here if ( $.type( tileSource ) == 'string' ) { - if ( tileSource.match( /\s*<.*/ ) ) { + //xml should start with "<" and end with ">" + if ( tileSource.match( /^\s*<.*>\s*$/ ) ) { tileSource = $.parseXml( tileSource ); - } else if ( tileSource.match( /\s*[\{\[].*/ ) ) { + //json should start with "{" or "[" and end with "}" or "]" + } else if ( tileSource.match(/^\s*[\{\[].*[\}\]]\s*$/ ) ) { tileSource = $.parseJSON(tileSource); } }