aboutsummaryrefslogtreecommitdiffstats
path: root/core/configmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2014-07-31 06:56:21 +0100
committerMatthew Wild <mwild1@gmail.com>2014-07-31 06:56:21 +0100
commit4fc9f0b8f590f64c2dd00455237ef5d46ded0d08 (patch)
treeaad7a8932b8bd03d895bd2713ee81c0cb7ef3f80 /core/configmanager.lua
parent559d43393be7558632d5c4845bf5b9078a39c264 (diff)
downloadprosody-4fc9f0b8f590f64c2dd00455237ef5d46ded0d08.tar.gz
prosody-4fc9f0b8f590f64c2dd00455237ef5d46ded0d08.zip
configmanager: nameprep VirtualHost and Component names
Diffstat (limited to 'core/configmanager.lua')
-rw-r--r--core/configmanager.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index d175b54b..c8aa7b9a 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -17,6 +17,9 @@ local envload = require"util.envload".envload;
local deps = require"util.dependencies";
local path_sep = package.config:sub(1,1);
+local have_encodings, encodings = pcall(require, "util.encodings");
+local nameprep = have_encodings and encodings.stringprep.nameprep or function (host) return host:lower(); end
+
module "configmanager"
local parsers = {};
@@ -170,6 +173,7 @@ do
rawset(env, "__currenthost", "*") -- Default is global
function env.VirtualHost(name)
+ name = nameprep(name);
if rawget(config, name) and rawget(config[name], "component_module") then
error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
name, config[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0);
@@ -187,6 +191,7 @@ do
env.Host, env.host = env.VirtualHost, env.VirtualHost;
function env.Component(name)
+ name = nameprep(name);
if rawget(config, name) and rawget(config[name], "defined") and not rawget(config[name], "component_module") then
error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s",
name, name, name), 0);