# HG changeset patch # User Matthew Wild # Date 1406786181 -3600 # Node ID 5926f01e5cd24cbc7893e85058ed86069418d35c # Parent 8029b8a5f37ae2bbb8a0ba18ecf2ba0d0f83d873 configmanager: nameprep VirtualHost and Component names diff -r 8029b8a5f37a -r 5926f01e5cd2 core/configmanager.lua --- a/core/configmanager.lua Fri Jul 25 13:53:39 2014 +0100 +++ b/core/configmanager.lua Thu Jul 31 06:56:21 2014 +0100 @@ -17,6 +17,9 @@ 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 @@ 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 @@ 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);