core.configmanager: Ensure Hosts are given names
authorKim Alvefur <zash@zash.se>
Sat, 02 Nov 2019 13:55:38 +0100
changeset 10378 a83233559253
parent 10377 51ea82f55322
child 10379 3d0adbc74c39
core.configmanager: Ensure Hosts are given names Prevents traceback from nameprep(nil)
core/configmanager.lua
--- a/core/configmanager.lua	Sat Nov 02 14:22:06 2019 +0100
+++ b/core/configmanager.lua	Sat Nov 02 13:55:38 2019 +0100
@@ -138,6 +138,9 @@
 
 		rawset(env, "__currenthost", "*") -- Default is global
 		function env.VirtualHost(name)
+			if not name then
+				error("Host must have a name", 2);
+			end
 			name = nameprep(name);
 			if rawget(config_table, name) and rawget(config_table[name], "component_module") then
 				error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
@@ -156,6 +159,9 @@
 		env.Host, env.host = env.VirtualHost, env.VirtualHost;
 
 		function env.Component(name)
+			if not name then
+				error("Component must have a name", 2);
+			end
 			name = nameprep(name);
 			if rawget(config_table, name) and rawget(config_table[name], "defined")
 				and not rawget(config_table[name], "component_module") then