Mercurial > prosody-modules
comparison mod_conformance_restricted/mod_conformance_restricted.lua @ 602:072b05999b4b
mod_conformance_restricted: Module to send XML restricted by RFC 6120 (for conformance testing)
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Tue, 07 Feb 2012 20:01:57 +0100 |
parents | |
children | 7c88e09a07e7 |
comparison
equal
deleted
inserted
replaced
595:7693724881b3 | 602:072b05999b4b |
---|---|
1 -- Prosody IM | |
2 -- Copyright (C) 2012 Florian Zeitz | |
3 -- | |
4 -- This project is MIT/X11 licensed. Please see the | |
5 -- COPYING file in the source package for more information. | |
6 -- | |
7 | |
8 local st = require "util.stanza"; | |
9 | |
10 module:hook("message/host", function (event) | |
11 local origin, stanza = event.origin, event.stanza; | |
12 local node, host, resource = jid.split(stanza.attr.to); | |
13 local body = stanza:get_child_text("body"); | |
14 | |
15 if resource ~= "conformance" then | |
16 return; -- Not interop testing | |
17 end | |
18 | |
19 if body == "PI" then | |
20 origin.send("<?testing this='out'?>"); | |
21 elseif body == "comment" then | |
22 origin.send("<!-- no comment -->"); | |
23 elseif body == "DTD" then | |
24 origin.send("<!DOCTYPE greeting [\n<!ENTITY test 'You should not see this'>\n]>"); | |
25 elseif body == "entity" then | |
26 origin.send("<message type='chat' to='"..stanza.attr.from.."'><body>&test;</body></message>"); | |
27 else | |
28 local reply = st.reply(stanza); | |
29 reply:body("Send me one of: PI, comment, DTD, or entity"); | |
30 origin.send(reply); | |
31 end | |
32 | |
33 return true; | |
34 end); |