changeset 13918:f0d854c63c8d 13.0

core.configmanager: Fix referencing previous config options #1950 Leaving the proxy metatable resulted in errors later when unexpected indices were accessed.
author Kim Alvefur <zash@zash.se>
date Sun, 27 Jul 2025 01:08:14 +0200
parents 9a69918b5e63
children 6ad72bd9a7ec 2169be3581ae
files core/configmanager.lua
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/core/configmanager.lua	Tue Jul 22 16:34:27 2025 +0100
+++ b/core/configmanager.lua	Sun Jul 27 01:08:14 2025 +0200
@@ -7,8 +7,8 @@
 --
 
 local _G = _G;
-local setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs =
-      setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs;
+local getmetatable, setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs =
+      getmetatable, setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs;
 local format, math_max, t_insert = string.format, math.max, table.insert;
 
 local envload = require"prosody.util.envload".envload;
@@ -169,6 +169,9 @@
 			error("Invalid syntax - missing '=' perhaps?", 2);
 		end;
 	};
+	local function is_config_option_proxy(v)
+		return getmetatable(v) == config_option_proxy_mt;
+	end
 
 	-- For reading config values out of files.
 	local function filereader(basepath, defaultmode)
@@ -262,6 +265,9 @@
 						t_insert(warnings, ("%s:%d: Duplicate option '%s'"):format(config_file, get_line_number(config_file), k));
 					end
 					set_options[option_path] = true;
+					if is_config_option_proxy(v) then
+						setmetatable(v, nil);
+					end
 					set(config_table, env.__currenthost or "*", k, v);
 				end
 		});