Annotate

mod_jid_prep/mod_jid_prep.lua @ 1356:a74ba847195a

mod_s2s_auth_dane: Drop support for domains without SRV for now
author Kim Alvefur <zash@zash.se>
date Tue, 18 Mar 2014 16:09:51 +0100
parent 1003:767999c39f0a
child 1404:99cb06b31ae8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1003
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 -- Run JIDs through stringprep processing on behalf of clients
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 -- http://xmpp.org/extensions/inbox/jidprep.html
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local jid_prep = require "util.jid".prep;
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local st = require "util.stanza";
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local xmlns_prep = "urn:xmpp:jidprep:tmp";
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 function prep_jid(event)
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local stanza = event.stanza;
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local jid = jid_prep(stanza:get_child_text("jid", xmlns_prep));
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 if not jid then
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 return event.origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 end
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 return event.origin.send(st.reply(stanza):tag("jid", { xmlns = xmlns_prep }):text(jid));
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 module:hook("iq/host/"..xmlns_prep..":jid", prep_jid);
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 module:depends("http");
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 module:provides("http", {
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 route = {
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 ["GET /*"] = function (event, jid)
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 return jid_prep(jid) or 400;
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 end;
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 }
767999c39f0a mod_jid_prep: Implement the JID prep protocol in the XEP submitted 5 minutes ago...
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 });