aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2010-04-05 13:09:29 -0400
committerChris Ball <cjb@laptop.org>2010-04-05 13:09:29 -0400
commitdc553ec9c0a172c51a69ce2fe9599c1123d493ba (patch)
tree7812a71d45caf8d629aa4856e7fab6985c025e3f
parent6d5f97d67df88ba77cb38f62c08dcba9fe306f87 (diff)
downloadetherpad-dc553ec9c0a172c51a69ce2fe9599c1123d493ba.tar.gz
etherpad-dc553ec9c0a172c51a69ce2fe9599c1123d493ba.tar.xz
etherpad-dc553ec9c0a172c51a69ce2fe9599c1123d493ba.zip
Make config parsing more robust
Previously, config booleans like etherpad.isProduction accepted only "true", and not "true " or " true" or "True" or "TRUE". Fix that.
-rw-r--r--etherpad/src/etherpad/globals.js4
-rw-r--r--etherpad/src/etherpad/pne/pne_utils.js3
-rw-r--r--etherpad/src/main.js3
-rw-r--r--infrastructure/net.appjet.oui/config.scala2
4 files changed, 8 insertions, 4 deletions
diff --git a/etherpad/src/etherpad/globals.js b/etherpad/src/etherpad/globals.js
index 343a989..8087337 100644
--- a/etherpad/src/etherpad/globals.js
+++ b/etherpad/src/etherpad/globals.js
@@ -22,8 +22,10 @@ var COMETPATH = "/comet";
var COLOR_PALETTE = ['#ffc7c7','#fff1c7','#e3ffc7','#c7ffd5','#c7ffff','#c7d5ff','#e3c7ff','#ffc7f1','#ff8f8f','#ffe38f','#c7ff8f','#8fffab','#8fffff','#8fabff','#c78fff','#ff8fe3','#d97979','#d9c179','#a9d979','#79d991','#79d9d9','#7991d9','#a979d9','#d979c1','#d9a9a9','#d9cda9','#c1d9a9','#a9d9b5','#a9d9d9','#a9b5d9','#c1a9d9','#d9a9cd'];
+var trueRegex = /\s*true\s*/i;
+
function isProduction() {
- return (appjet.config['etherpad.isProduction'] == "true");
+ return (trueRegex.test(appjet.config['etherpad.isProduction']));
}
var SUPERDOMAINS = {
diff --git a/etherpad/src/etherpad/pne/pne_utils.js b/etherpad/src/etherpad/pne/pne_utils.js
index 3169407..bc105bd 100644
--- a/etherpad/src/etherpad/pne/pne_utils.js
+++ b/etherpad/src/etherpad/pne/pne_utils.js
@@ -72,7 +72,8 @@ function checkDbVersionUpgrade() {
var dbVersion = parseVersionString(dbVersionString);
var runningVersion = getVersionNumbers();
- var force = (appjet.config['etherpad.forceDbUpgrade'] == "true");
+ var trueRegex = /\s*true\s*/i;
+ var force = trueRegex.test(appjet.config['etherpad.forceDbUpgrade']);
if (!force && (runningVersion.major != dbVersion.major)) {
println("Error: you are attempting to update an EtherPad["+dbVersionString+
diff --git a/etherpad/src/main.js b/etherpad/src/main.js
index 745f5fa..c881223 100644
--- a/etherpad/src/main.js
+++ b/etherpad/src/main.js
@@ -259,7 +259,8 @@ function checkRequestIsWellFormed() {
// checkHost()
//----------------------------------------------------------------
function checkHost() {
- if (appjet.config['etherpad.skipHostnameCheck'] == "true") {
+ var trueRegex = /\s*true\s*/i;
+ if (trueRegex.test(appjet.config['etherpad.skipHostnameCheck'])) {
return;
}
diff --git a/infrastructure/net.appjet.oui/config.scala b/infrastructure/net.appjet.oui/config.scala
index 46e73cf..6201816 100644
--- a/infrastructure/net.appjet.oui/config.scala
+++ b/infrastructure/net.appjet.oui/config.scala
@@ -41,7 +41,7 @@ object config {
null;
}
}
- def boolOrElse(name: String, default: Boolean) = values.get(name).map(_.equals("true")).getOrElse(default);
+ def boolOrElse(name: String, default: Boolean) = values.get(name).map(_.matches("(?i)\\s*true\\s*")).getOrElse(default);
def intOrElse(name: String, default: Int) = values.get(name).map(Integer.parseInt(_)).getOrElse(default);
def longOrElse(name: String, default: Long) = values.get(name).map(java.lang.Long.parseLong(_)).getOrElse(default);