Changeset

13872:76582d10bc09 default tip

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 05 May 2025 17:30:06 +0200
parents 13866:7f6916088278 (current diff) 13871:9eee04a95a25 (diff)
children
files teal-src/prosody/util/jsonschema.tl util/jsonschema.lua
diffstat 7 files changed, 47 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/net/http/files.lua	Mon May 05 17:14:57 2025 +0200
+++ b/net/http/files.lua	Mon May 05 17:30:06 2025 +0200
@@ -90,11 +90,12 @@
 			return 304;
 		end
 
-		local data = cache:get(orig_path);
-		if data and data.etag == etag then
-			response_headers.content_type = data.content_type;
-			data = data.data;
-			cache:set(orig_path, data);
+		local data;
+		local cached = cache:get(orig_path);
+		if cached and cached.etag == etag then
+			response_headers.content_type = cached.content_type;
+			data = cached.data;
+			cache:set(orig_path, cached);
 		elseif attr.mode == "directory" and path then
 			if full_path:sub(-1) ~= "/" then
 				local dir_path = { is_absolute = true, is_directory = true };
--- a/plugins/mod_admin_shell.lua	Mon May 05 17:14:57 2025 +0200
+++ b/plugins/mod_admin_shell.lua	Mon May 05 17:30:06 2025 +0200
@@ -1587,7 +1587,7 @@
 
 	for _, session in pairs(s2s_sessions) do
 		local id = session.id or (session.type .. tostring(session):match("[a-f0-9]+$"));
-		if (match_id and match_id == id) or ((from and match_wildcard(from, session.to_host)) or (to and match_wildcard(to, session.to_host))) then
+		if (match_id and match_id == id) or ((from and match_wildcard(from, session.from_host)) and (to and match_wildcard(to, session.to_host))) then
 			print(("Closing connection from %s to %s [%s]"):format(session.from_host, session.to_host, id));
 			(session.close or s2smanager.destroy_session)(session, build_reason(text, condition));
 			count = count + 1;
--- a/plugins/muc/register.lib.lua	Mon May 05 17:14:57 2025 +0200
+++ b/plugins/muc/register.lib.lua	Mon May 05 17:30:06 2025 +0200
@@ -172,9 +172,13 @@
 			origin.send(st.error_reply(stanza, "modify", "bad-request", "Error in form"));
 			return true;
 		end
-		local reg_data = registration_form:data(form_tag);
-		if not reg_data then
-			origin.send(st.error_reply(stanza, "modify", "bad-request", "Error in form"));
+		local reg_data, form_err = registration_form:data(form_tag);
+		if form_err then
+			local errs = {};
+			for field, err in pairs(form_err) do
+				table.insert(errs, field..": "..err);
+			end
+			origin.send(st.error_reply(stanza, "modify", "bad-request", "Error in form: "..table.concat(errs)));
 			return true;
 		end
 		-- Is the nickname valid?
--- a/spec/util_jsonschema_spec.lua	Mon May 05 17:14:57 2025 +0200
+++ b/spec/util_jsonschema_spec.lua	Mon May 05 17:30:06 2025 +0200
@@ -31,7 +31,10 @@
 	["patternProperties.json"] = "NYI",
 	["properties.json:1:2"] = "NYI",
 	["properties.json:1:3"] = "NYI",
+	["propertyNames.json:1:1"] = "NYI",
 	["ref.json:0:3"] = "util.jsonpointer recursive issue?",
+	["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?",
+	["ref.json:6:1"] = "NYI",
 	["ref.json:11"] = "NYI",
 	["ref.json:12:1"] = "FIXME",
 	["ref.json:13"] = "NYI",
@@ -41,28 +44,26 @@
 	["ref.json:17"] = "NYI",
 	["ref.json:18"] = "NYI",
 	["ref.json:19"] = "NYI",
+	["ref.json:20"] = "NYI",
+	["ref.json:25"] = "NYI",
 	["ref.json:26"] = "NYI",
 	["ref.json:27"] = "NYI",
 	["ref.json:28"] = "NYI",
-	["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?",
-	["required.json:4"] = "JavaScript specific and distinguishing objects from arrays",
-	["ref.json:6:1"] = "NYI",
-	["ref.json:20"] = "NYI",
-	["ref.json:25"] = "NYI",
 	["ref.json:29"] = "NYI",
 	["ref.json:30"] = "NYI",
 	["ref.json:31"] = "NYI",
 	["ref.json:32"] = "NYI",
 	["not.json:6"] = "NYI",
+	["required.json:0:2"] = "distinguishing objects from arrays",
+	["required.json:4"] = "JavaScript specific and distinguishing objects from arrays",
+	["not.json:8:0"] = "NYI",
 	["refRemote.json"] = "DEFINITELY NYI",
-	["required.json:0:2"] = "distinguishing objects from arrays",
 	["type.json:0:1"] = "1.0 is not an integer!",
 	["type.json:3:4"] = "distinguishing objects from arrays",
 	["type.json:3:6"] = "null is weird",
 	["type.json:4:3"] = "distinguishing objects from arrays",
 	["type.json:4:6"] = "null is weird",
 	["type.json:9:4"] = "null is weird",
-	["type.json:9:6"] = "null is weird",
 	["unevaluatedItems.json"] = "NYI",
 	["unevaluatedProperties.json"] = "NYI",
 	["uniqueItems.json:0:10"] = "deepcompare",
--- a/teal-src/prosody/util/jsonschema.tl	Mon May 05 17:14:57 2025 +0200
+++ b/teal-src/prosody/util/jsonschema.tl	Mon May 05 17:30:06 2025 +0200
@@ -311,7 +311,7 @@
 		end
 	end
 
-	if schema["not"] then
+	if schema["not"] ~= nil then
 		if validate(schema["not"], data, root, sloc.."/not", iloc, errs) then
 			table.insert(errs, mkerr(sloc.."/not", iloc, "did match subschema"))
 			return false, errs
@@ -320,14 +320,14 @@
 
 	if schema["if"] ~= nil then
 		if validate(schema["if"], data, root, sloc.."/if", iloc, errs) then
-			if schema["then"] then
+			if schema["then"] ~= nil then
 				if not validate(schema["then"], data, root, sloc.."/then", iloc, errs) then
 					table.insert(errs, mkerr(sloc.."/then", iloc, "did not match subschema"))
 					return false, errs
 				end
 			end
 		else
-			if schema["else"] then
+			if schema["else"] ~= nil then
 				if not validate(schema["else"], data, root, sloc.."/else", iloc, errs) then
 					table.insert(errs, mkerr(sloc.."/else", iloc, "did not match subschema"))
 					return false, errs
--- a/util/jsonschema.lua	Mon May 05 17:14:57 2025 +0200
+++ b/util/jsonschema.lua	Mon May 05 17:30:06 2025 +0200
@@ -184,7 +184,7 @@
 		end
 	end
 
-	if schema["not"] then
+	if schema["not"] ~= nil then
 		if validate(schema["not"], data, root, sloc .. "/not", iloc, errs) then
 			table.insert(errs, mkerr(sloc .. "/not", iloc, "did match subschema"))
 			return false, errs
@@ -193,14 +193,14 @@
 
 	if schema["if"] ~= nil then
 		if validate(schema["if"], data, root, sloc .. "/if", iloc, errs) then
-			if schema["then"] then
+			if schema["then"] ~= nil then
 				if not validate(schema["then"], data, root, sloc .. "/then", iloc, errs) then
 					table.insert(errs, mkerr(sloc .. "/then", iloc, "did not match subschema"))
 					return false, errs
 				end
 			end
 		else
-			if schema["else"] then
+			if schema["else"] ~= nil then
 				if not validate(schema["else"], data, root, sloc .. "/else", iloc, errs) then
 					table.insert(errs, mkerr(sloc .. "/else", iloc, "did not match subschema"))
 					return false, errs
--- a/util/prosodyctl/check.lua	Mon May 05 17:14:57 2025 +0200
+++ b/util/prosodyctl/check.lua	Mon May 05 17:30:06 2025 +0200
@@ -1096,11 +1096,27 @@
 				target_hosts:remove("localhost");
 			end
 
+			local function check_record(name, rtype)
+				local res, err = dns.lookup(name, rtype);
+				if err then
+					print("    Problem looking up "..rtype.." record for '"..name.."': "..err);
+				elseif res and res.bogus then
+					print("    Problem looking up "..rtype.." record for '"..name.."': "..res.bogus);
+				elseif res and res.rcode and res.rcode ~= 0 and res.rcode ~= 3 then
+					print("    Problem looking up "..rtype.." record for '"..name.."': "..res.status);
+				end
+				return res and #res > 0;
+			end
+
 			local function check_address(target)
-				local A, AAAA = dns.lookup(idna.to_ascii(target), "A"), dns.lookup(idna.to_ascii(target), "AAAA");
 				local prob = {};
-				if use_ipv4 and not (A and #A > 0) then table.insert(prob, "A"); end
-				if use_ipv6 and not (AAAA and #AAAA > 0) then table.insert(prob, "AAAA"); end
+				local aname = idna.to_ascii(target);
+				if not aname then
+					print("    '" .. target .. "' is not a valid hostname");
+					return prob;
+				end
+				if use_ipv4 and not check_record(aname, "A") then table.insert(prob, "A"); end
+				if use_ipv6 and not check_record(aname, "AAAA") then table.insert(prob, "AAAA"); end
 				return prob;
 			end