From fc5ec1922a6608681362b7545d9b8b87ca8e5c4c Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 19 Nov 2013 13:46:16 +0100 Subject: [PATCH] Don't try validating JSON-ish settings in /admin/settings fixes #1965 --- src/static/js/admin/settings.js | 41 ++++++--------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/src/static/js/admin/settings.js b/src/static/js/admin/settings.js index ebe4a25a9..b30809bbc 100644 --- a/src/static/js/admin/settings.js +++ b/src/static/js/admin/settings.js @@ -13,28 +13,18 @@ $(document).ready(function () { socket.on('settings', function (settings) { - /* Check to make sure the JSON is clean before proceeding */ - if(isJSONClean(settings.results)) - { - $('.settings').append(settings.results); - $('.settings').focus(); - $('.settings').autosize(); - } - else{ - alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD"); - } + // (removed JSON validation, cause it's not JSON!) + $('.settings').append(settings.results); + $('.settings').focus(); + $('.settings').autosize(); }); /* When the admin clicks save Settings check the JSON then send the JSON back to the server */ $('#saveSettings').on('click', function(){ var editedSettings = $('.settings').val(); - if(isJSONClean(editedSettings)){ - // JSON is clean so emit it to the server - socket.emit("saveSettings", $('.settings').val()); - }else{ - alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD") - $('.settings').focus(); - } + // (removed JSON validation, cause it's not JSON!) + // emit it to the server + socket.emit("saveSettings", $('.settings').val()); }); /* Tell Etherpad Server to restart */ @@ -51,20 +41,3 @@ $(document).ready(function () { socket.emit("load"); // Load the JSON from the server }); - - -function isJSONClean(data){ - var cleanSettings = JSON.minify(data); - try{ - var response = jQuery.parseJSON(cleanSettings); - } - catch(e){ - return false; // the JSON failed to be parsed - } - if(typeof response !== 'object'){ - return false; - }else{ - return true; - } -} -