diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-06-02 18:23:39 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-06-02 18:23:39 +0100 |
commit | a1c37ed3700ebf9cd693a0aa198b2760564f2e61 (patch) | |
tree | 100a3bfe5da332dc0cef1462e97d4c98fbe3feba | |
parent | cb5b77242767f60d54624708cfca01bb9f1671a6 (diff) | |
download | prosody-a1c37ed3700ebf9cd693a0aa198b2760564f2e61.tar.gz prosody-a1c37ed3700ebf9cd693a0aa198b2760564f2e61.zip |
xmppserver_listener: Add filters for incoming bytes and stanzas
-rw-r--r-- | net/xmppserver_listener.lua | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua index 256c1f72..8700e6f2 100644 --- a/net/xmppserver_listener.lua +++ b/net/xmppserver_listener.lua @@ -125,16 +125,26 @@ local function initialize_session(session) session.stream:reset(); end + local filter = session.filter; function session.data(data) - local ok, err = stream:feed(data); - if ok then return; end - (session.log or log)("warn", "Received invalid XML: %s", data); - (session.log or log)("warn", "Problem was: %s", err); - session:close("xml-not-well-formed"); + data = filter("bytes/in", data); + if data then + local ok, err = stream:feed(data); + if ok then return; end + (session.log or log)("warn", "Received invalid XML: %s", data); + (session.log or log)("warn", "Problem was: %s", err); + session:close("xml-not-well-formed"); + end end session.close = session_close; - session.dispatch_stanza = stream_callbacks.handlestanza; + local handlestanza = stream_callbacks.handlestanza; + function session.dispatch_stanza(session, stanza) + stanza = filters("stanzas/in", stanza); + if stanza then + return handlestanza(session, stanza); + end + end end function xmppserver.onconnect(conn) |