From 7550be09216807b7bacd036327f44726f148272c Mon Sep 17 00:00:00 2001 From: s1341 Date: Tue, 19 Nov 2013 18:16:59 +0200 Subject: [PATCH 1/3] strip off trailing commas --- src/static/js/admin/settings.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/static/js/admin/settings.js b/src/static/js/admin/settings.js index ebe4a25a..fb3f2e97 100644 --- a/src/static/js/admin/settings.js +++ b/src/static/js/admin/settings.js @@ -55,6 +55,8 @@ $(document).ready(function () { function isJSONClean(data){ var cleanSettings = JSON.minify(data); + // this is a bit naive. In theory some key/value might contain the sequences ',]' or ',}' + cleanSettings = cleanSettings.replace(",]","]").replace(",}","}"); try{ var response = jQuery.parseJSON(cleanSettings); } From 9b7203d4d2400c44931c303356e1b02e695ee84d Mon Sep 17 00:00:00 2001 From: s1341 Date: Tue, 26 Nov 2013 10:20:59 +0200 Subject: [PATCH 2/3] have the server parse the settings file using minify and strip commas --- src/node/utils/Settings.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 2576aeab..ee696b03 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -1,5 +1,5 @@ /** - * The Settings Modul reads the settings out of settings.json and provides + * The Settings Modul reads the settings out of settings.json and provides * this information to the other modules */ @@ -24,7 +24,7 @@ var os = require("os"); var path = require('path'); var argv = require('./Cli').argv; var npm = require("npm/lib/npm.js"); -var vm = require('vm'); +var jsonminify = require("jsonminify"); var log4js = require("log4js"); var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; @@ -48,7 +48,7 @@ exports.faviconTimeslider = "../../" + exports.favicon; * The IP ep-lite should listen to */ exports.ip = "0.0.0.0"; - + /** * The Port ep-lite should listen to */ @@ -166,8 +166,8 @@ exports.reloadSettings = function reloadSettings() { var settings; try { if(settingsStr) { - settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json"); - settings = JSON.parse(JSON.stringify(settings)); // fix objects having constructors of other vm.context + settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}"); + settings = JSON.parse(settingsStr); } }catch(e){ console.error('There was an error processing your settings.json file: '+e.message); @@ -195,7 +195,7 @@ exports.reloadSettings = function reloadSettings() { console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); } } - + log4js.configure(exports.logconfig);//Configure the logging appenders log4js.setGlobalLogLevel(exports.loglevel);//set loglevel log4js.replaceConsole(); From 5181b3e4671da24ba09a21615ac6c8dbebe8e769 Mon Sep 17 00:00:00 2001 From: s1341 Date: Tue, 26 Nov 2013 10:28:33 +0200 Subject: [PATCH 3/3] add josnminify to package.json --- src/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/package.json b/src/package.json index 931db163..0c59cfbb 100644 --- a/src/package.json +++ b/src/package.json @@ -5,7 +5,7 @@ "keywords" : ["etherpad", "realtime", "collaborative", "editor"], "author" : "Peter 'Pita' Martischka - Primary Technology Ltd", "contributors" : [ - { "name": "John McLear" }, + { "name": "John McLear" }, { "name": "Hans Pinckaers" }, { "name": "Robin Buse" }, { "name": "Marcel Klehr" } @@ -39,6 +39,7 @@ "languages4translatewiki" : "0.1.3", "swagger-node-express" : "1.2.3", "channels" : "0.0.x", + "jsonminify" : "0.2.2", "measured" : "0.1.3" }, "bin": { "etherpad-lite": "./node/server.js" }, @@ -47,7 +48,7 @@ }, "engines" : { "node" : ">=0.6.3", "npm" : ">=1.0" - }, + }, "repository" : { "type" : "git", "url" : "http://github.com/ether/etherpad-lite.git" },