From c69b4e90b644b7790d55578ac174140763993bb9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 21 Nov 2008 10:02:16 +0000 Subject: [PATCH] detect and handle incorrect stream start. Fixes #4499 --- src/common/xmpp/dispatcher_nb.py | 4 ++++ src/common/xmpp/simplexml.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index a17e6aa26..ee0eebdf6 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -141,6 +141,10 @@ class Dispatcher(PlugIn): self.DEBUG('Invalid XML received from server. Forcing disconnect.', 'error') self._owner.Connection.pollend() return 0 + except ValueError, e: + self.DEBUG(str(e), 'error') + self._owner.Connection.pollend() + return 0 if len(self._pendingExceptions) > 0: _pendingException = self._pendingExceptions.pop() raise _pendingException[0], _pendingException[1], _pendingException[2] diff --git a/src/common/xmpp/simplexml.py b/src/common/xmpp/simplexml.py index 91f733774..fc735ffab 100644 --- a/src/common/xmpp/simplexml.py +++ b/src/common/xmpp/simplexml.py @@ -386,7 +386,11 @@ class NodeBuilder: else: self._document_attrs[attr] = val ns = self._document_nsp.get(nsp, 'http://www.gajim.org/xmlns/undeclared-root') - self.stream_header_received(ns, name, attrs) + try: + self.stream_header_received(ns, name, attrs) + except ValueError, e: + self._document_attrs = None + raise ValueError(str(e)) if not self.last_is_data and self._ptr.parent: self._ptr.parent.data.append('') self.last_is_data = 0