changeset 6509:f61564e11d3b

various: Adjust for loop variables becoming constants in Lua 5.5
author Kim Alvefur <zash@zash.se>
date Tue, 07 Apr 2026 14:30:31 +0200
parents 3044e14fcaa0
children 317fb60e8cad
files mod_dnsbl/mod_dnsbl.lua mod_firewall/actions.lib.lua mod_firewall/conditions.lib.lua mod_firewall/mod_firewall.lua mod_migrate/mod_migrate.lua mod_pubsub_feeds/mod_pubsub_feeds.lua mod_storage_appendmap/mod_storage_appendmap.lua mod_storage_s3/mod_storage_s3.lua
diffstat 8 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mod_dnsbl/mod_dnsbl.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_dnsbl/mod_dnsbl.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -52,9 +52,9 @@
 	end
 
 	local n_line, n_added = 0, 0;
-	for line in f:lines() do
+	for rawline in f:lines() do
 		n_line = n_line + 1;
-		line = line:gsub("#.+$", ""):match("^%s*(.-)%s*$");
+		local line = rawline:gsub("#.+$", ""):match("^%s*(.-)%s*$");
 		if line == "" then -- luacheck: ignore 542
 			-- Skip
 		else
--- a/mod_firewall/actions.lib.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_firewall/actions.lib.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -12,7 +12,7 @@
 local function compile_xml(data)
 	local code = {};
 	local first, short_close = true, nil;
-	for tagline, text in data:gmatch("<([^>]+)>([^<]*)") do
+	for _, tagline, text in data:gmatch("()<([^>]+)>([^<]*)") do
 		if tagline:sub(-1,-1) == "/" then
 			tagline = tagline:sub(1, -2);
 			short_close = true;
--- a/mod_firewall/conditions.lib.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_firewall/conditions.lib.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -173,8 +173,8 @@
 
 function condition_handlers.CROSSING_GROUPS(group_names)
 	local code = {};
-	for group_name in group_names:gmatch("([^, ][^,]+)") do
-		group_name = group_name:match("^%s*(.-)%s*$"); -- Trim leading/trailing whitespace
+	for wgroup_name in group_names:gmatch("([^, ][^,]+)") do
+		local group_name = wgroup_name:match("^%s*(.-)%s*$"); -- Trim leading/trailing whitespace
 		-- Just check that's it is crossing from outside group to inside group
 		table.insert(code, ("(group_contains(%q, bare_to) and group_contains(%q, bare_from))"):format(group_name, group_name))
 	end
@@ -254,9 +254,9 @@
 
 function condition_handlers.TIME(ranges)
 	local conditions = {};
-	for range in ranges:gmatch("([^,]+)") do
+	for rawrange in ranges:gmatch("([^,]+)") do
 		local clause = {};
-		range = range:lower()
+		local range = rawrange:lower()
 			:gsub("(%d+):?(%d*) *am", function (h, m) return tostring(tonumber(h)%12)..":"..(tonumber(m) or "00"); end)
 			:gsub("(%d+):?(%d*) *pm", function (h, m) return tostring(tonumber(h)%12+12)..":"..(tonumber(m) or "00"); end);
 		local start_hour, start_minute = range:match("(%d+):(%d+) *%-");
--- a/mod_firewall/mod_firewall.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_firewall/mod_firewall.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -414,8 +414,8 @@
 	local state; -- nil -> "rules" -> "actions" -> nil -> ...
 
 	local line_hold;
-	for line in file:lines() do
-		line = line:match("^%s*(.-)%s*$");
+	for rawline in file:lines() do
+		local line = rawline:match("^%s*(.-)%s*$");
 		if line_hold and line:sub(-1,-1) ~= "\\" then
 			line = line_hold..line;
 			line_hold = nil;
--- a/mod_migrate/mod_migrate.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_migrate/mod_migrate.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -88,7 +88,8 @@
 	end
 	sm.initialize_host(host);
 	um.initialize_host(host);
-	for source_store in source_stores:gmatch("[^,]+") do
+	for source_store_with_type in source_stores:gmatch("[^,]+") do
+		local source_store = source_store_with_type;
 		local store_type = source_store:match("%-(%a+)$");
 		if store_type then
 			source_store = source_store:sub(1, -2-#store_type);
--- a/mod_pubsub_feeds/mod_pubsub_feeds.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_pubsub_feeds/mod_pubsub_feeds.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -42,7 +42,8 @@
 	local ok, nodes = pubsub.service:get_nodes(true);
 	if not ok then nodes = {}; end
 	local new_feed_list = {};
-	for node, url in pairs(config) do
+	for i, url in pairs(config) do
+		local node = i;
 		if type(node) == "number" then
 			node = url;
 		end
--- a/mod_storage_appendmap/mod_storage_appendmap.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_storage_appendmap/mod_storage_appendmap.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -50,10 +50,8 @@
 local function serialize_map(keyvalues)
 	local keys, values = {}, {};
 	for key, value in pairs(keyvalues) do
-		key = serialize_key(key);
-		value = serialize_value(value);
-		table.insert(keys, key);
-		table.insert(values, value);
+		table.insert(keys, serialize_key(key));
+		table.insert(values, serialize_key(key));
 	end
 	return table.concat(keys, ", ") .. " = " .. table.concat(values, ", ") .. ";\n";
 end
--- a/mod_storage_s3/mod_storage_s3.lua	Tue Apr 07 06:51:05 2026 +0200
+++ b/mod_storage_s3/mod_storage_s3.lua	Tue Apr 07 14:30:31 2026 +0200
@@ -76,8 +76,8 @@
 		request.query = canonical_query;
 	end
 
-	for header_name, header_value in it.sorted_pairs(headers) do
-		header_name = header_name:lower();
+	for raw_header_name, header_value in it.sorted_pairs(headers) do
+		local header_name = raw_header_name:lower();
 		canonical_headers:push(header_name .. ":" .. header_value .. "\n");
 		signed_headers:push(header_name);
 	end