Software /
code /
prosody
Comparison
net/xmppclient_listener.lua @ 557:c9b3ffb08fe3
Disconnect with stream errors on bad XML, or invalid stream namespace
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 02:02:57 +0000 |
parent | 545:60002993be04 |
child | 559:fa4a51fe6442 |
comparison
equal
deleted
inserted
replaced
556:624367a765cd | 557:c9b3ffb08fe3 |
---|---|
34 local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; --import("core.sessionmanager", "new_session", "destroy_session"); | 34 local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; --import("core.sessionmanager", "new_session", "destroy_session"); |
35 local sm_streamopened = sessionmanager.streamopened; | 35 local sm_streamopened = sessionmanager.streamopened; |
36 local sm_streamclosed = sessionmanager.streamclosed; | 36 local sm_streamclosed = sessionmanager.streamclosed; |
37 local st = stanza; | 37 local st = stanza; |
38 | 38 |
39 local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza }; | 39 local stream_callbacks = { ns = "http://etherx.jabber.org/streams", streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza }; |
40 | |
41 function stream_callbacks.error(session, error, data) | |
42 if error == "no-stream" then | |
43 session:close("invalid-namespace"); | |
44 else | |
45 session.log("debug", "Client XML parse error: %s", tostring(error)); | |
46 session:close("xml-not-well-formed"); | |
47 end | |
48 end | |
40 | 49 |
41 local sessions = {}; | 50 local sessions = {}; |
42 local xmppclient = { default_port = 5222, default_mode = "*a" }; | 51 local xmppclient = { default_port = 5222, default_mode = "*a" }; |
43 | 52 |
44 -- These are session methods -- | 53 -- These are session methods -- |
49 session.parser = parser; | 58 session.parser = parser; |
50 | 59 |
51 session.notopen = true; | 60 session.notopen = true; |
52 | 61 |
53 function session.data(conn, data) | 62 function session.data(conn, data) |
54 parser:parse(data); | 63 local ok, err = parser:parse(data); |
64 if ok then return; end | |
65 session:close("xml-not-well-formed"); | |
55 end | 66 end |
67 | |
56 return true; | 68 return true; |
57 end | 69 end |
58 | 70 |
59 | 71 |
60 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; | 72 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; |