1 -- Run JIDs through stringprep processing on behalf of clients
2 -- http://xmpp.org/extensions/inbox/jidprep.html
4 local jid_prep
= require
"util.jid".prep
;
5 local st
= require
"util.stanza";
7 local xmlns_prep
= "urn:xmpp:jidprep:0";
9 module
:add_feature(xmlns_prep
);
11 function prep_jid(event
)
12 local stanza
= event
.stanza
;
13 local jid
= jid_prep(stanza
:get_child_text("jid", xmlns_prep
));
15 return event
.origin
.send(st
.error_reply(stanza
, "modify", "jid-malformed"));
17 return event
.origin
.send(st
.reply(stanza
):tag("jid", { xmlns
= xmlns_prep
}):text(jid
));
21 module
:hook("iq/host/"..xmlns_prep
..":jid", prep_jid
);
23 module
:depends("http");
24 module
:provides("http", {
26 ["GET /*"] = function (event
, jid
)
27 return jid_prep(jid
) or 400;