From f7f2f501f5ab9dacd37859625c8a898dbe60315c Mon Sep 17 00:00:00 2001 From: aplave Date: Sun, 22 Dec 2019 10:32:17 -0800 Subject: [PATCH] Wrap URL parameter decoding in try-catch for safety --- src/openseadragon.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 8ecd2f3b..6840e53d 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -2586,8 +2586,13 @@ function OpenSeadragon( options ){ sep = part.indexOf( '=' ); if ( sep > 0 ) { - URLPARAMS[ part.substring( 0, sep ) ] = - decodeURIComponent( part.substring( sep + 1 ) ); + var key = part.substring( 0, sep ), + value = part.substring( sep + 1 ); + try { + URLPARAMS[ key ] = decodeURIComponent( value ); + } catch (e) { + $.console.error( "Ignoring malformed URL parameter: %s=%s", key, value ); + } } }