Diff

core/configmanager.lua @ 6326:a3b9496673ee

Merge 0.9->0.10
author Matthew Wild <mwild1@gmail.com>
date Thu, 31 Jul 2014 07:11:54 +0100
parent 6167:5af7fe1014db
parent 6323:5926f01e5cd2
child 6712:29d5875ae38d
line wrap: on
line diff
--- a/core/configmanager.lua	Fri Jul 25 21:03:16 2014 +0200
+++ b/core/configmanager.lua	Thu Jul 31 07:11:54 2014 +0100
@@ -19,6 +19,9 @@
 local glob_to_pattern = require"util.paths".glob_to_pattern;
 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"
 
 _M.resolve_relative_path = resolve_relative_path; -- COMPAT
@@ -139,6 +142,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);
@@ -156,6 +160,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);