File

mod_jid_prep/mod_jid_prep.lua @ 6299:611380cfad75

mod_csi_grace_period: Readme Fix Tab at beginning of line diff --git a/mod_csi_grace_period/README.md b/mod_csi_grace_period/README.md --- a/mod_csi_grace_period/README.md +++ b/mod_csi_grace_period/README.md @@ -16,9 +16,9 @@ pocket is not the best use of radio time Works with [mod_csi_simple][doc:modules:mod_csi_simple] which is included with Prosody. - ------- ------- - trunk* Works - 13 Works - 0.12 Works + ------- ------- + trunk* Works + 13 Works + 0.12 Works - *as of 2025-06-13 + *as of 2025-06-13
author Menel <menel@snikket.de>
date Fri, 13 Jun 2025 10:08:21 +0200
parent 1404:99cb06b31ae8
line wrap: on
line source

-- Run JIDs through stringprep processing on behalf of clients
-- http://xmpp.org/extensions/inbox/jidprep.html

local jid_prep = require "util.jid".prep;
local st = require "util.stanza";

local xmlns_prep = "urn:xmpp:jidprep:0";

module:add_feature(xmlns_prep);

function prep_jid(event)
	local stanza = event.stanza;
	local jid = jid_prep(stanza:get_child_text("jid", xmlns_prep));
	if not jid then
		return event.origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
	end
	return event.origin.send(st.reply(stanza):tag("jid", { xmlns = xmlns_prep }):text(jid));
end


module:hook("iq/host/"..xmlns_prep..":jid", prep_jid);

module:depends("http");
module:provides("http", {
	route = {
		["GET /*"] = function (event, jid)
			return jid_prep(jid) or 400;
		end;
	}
});