view mod_jid_prep/mod_jid_prep.lua @ 5160:8474a3b80200

mod_firewall: Fix 'is_admin' internal dependency rule #1797 (thanks diane) Looks like the boolean logic was inverted here. Instead, for now, simply check if is_admin is there. It is deprecated in trunk and was briefly removed before being brought back with a 'deprecated' warning as part of the new roles and permissions work. Making this dependency conditioned on the existence of the underlying function should make it work until it actually goes away for real.
author Kim Alvefur <zash@zash.se>
date Fri, 27 Jan 2023 23:06:25 +0100
parents 99cb06b31ae8
children
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;
	}
});