From 91153250d5c15de644fad4dbc71cb44c16b1453a Mon Sep 17 00:00:00 2001 From: Hrithik248 <135501622+Hrithik248@users.noreply.github.com> Date: Wed, 12 Jul 2023 13:22:42 +0530 Subject: [PATCH] invalid JSON is checked using parse and wrapping it in try catch blocks. --- src/jquery.i18n.messagestore.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/jquery.i18n.messagestore.js b/src/jquery.i18n.messagestore.js index ba81ce5..53dd547 100644 --- a/src/jquery.i18n.messagestore.js +++ b/src/jquery.i18n.messagestore.js @@ -26,7 +26,12 @@ $.getJSON( url ) .done( deferred.resolve ) .fail( function ( jqxhr, settings, exception ) { - $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception ); + try { + JSON.parse(jqxhr.responseText); + } catch (error) { + $.i18n.log( 'Invalid JSON', error ); + deferred.reject(); + } // Ignore 404 exception, because we are handling fallabacks explicitly deferred.resolve(); } );