Comparison

mod_jid_prep/mod_jid_prep.lua @ 1003:767999c39f0a

mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 May 2013 23:30:50 +0100
child 1404:99cb06b31ae8
comparison
equal deleted inserted replaced
1002:225d3ba1eb7b 1003:767999c39f0a
1 -- Run JIDs through stringprep processing on behalf of clients
2 -- http://xmpp.org/extensions/inbox/jidprep.html
3
4 local jid_prep = require "util.jid".prep;
5 local st = require "util.stanza";
6
7 local xmlns_prep = "urn:xmpp:jidprep:tmp";
8
9 function prep_jid(event)
10 local stanza = event.stanza;
11 local jid = jid_prep(stanza:get_child_text("jid", xmlns_prep));
12 if not jid then
13 return event.origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
14 end
15 return event.origin.send(st.reply(stanza):tag("jid", { xmlns = xmlns_prep }):text(jid));
16 end
17
18
19 module:hook("iq/host/"..xmlns_prep..":jid", prep_jid);
20
21 module:depends("http");
22 module:provides("http", {
23 route = {
24 ["GET /*"] = function (event, jid)
25 return jid_prep(jid) or 400;
26 end;
27 }
28 });