From aa9de25923d41dc34aa448fcf4b848b6a0ae8e07 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 10 May 2005 09:27:04 +0000 Subject: [PATCH] Alexey patch that allows discover that server is violating RFC by not restarting stream after TLS start. If server did such thing xmpppy will not crash unpredictely but will issue a appropriate exception. --- src/common/xmpp/dispatcher.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/xmpp/dispatcher.py b/src/common/xmpp/dispatcher.py index 3ca0d7c74..017e43ad6 100644 --- a/src/common/xmpp/dispatcher.py +++ b/src/common/xmpp/dispatcher.py @@ -89,6 +89,7 @@ class Dispatcher(PlugIn): self.Stream=simplexml.NodeBuilder() self.Stream._dispatch_depth=2 self.Stream.dispatch=self.dispatch + self.Stream.stream_header_received=self._check_stream_start self._owner.debug_flags.append(simplexml.DBG_NODEBUILDER) self.Stream.DEBUG=self._owner.DEBUG self.Stream.features=None @@ -99,6 +100,10 @@ class Dispatcher(PlugIn): self._metastream.setAttr('to',self._owner.Server) self._owner.send("%s>"%str(self._metastream)[:-2]) + def _check_stream_start(self,ns,tag,attrs): + if ns<>NS_STREAMS or tag<>'stream': + raise ValueError('Incorrect stream start: (%s,%s). Terminating.'%(tag,ns)) + def Process(self, timeout=0): """ Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time. Returns: