detect and handle incorrect stream start. Fixes #4499

This commit is contained in:
Yann Leboulanger 2008-11-21 10:02:16 +00:00
parent 4728a3d960
commit c69b4e90b6
2 changed files with 9 additions and 1 deletions

View File

@ -141,6 +141,10 @@ class Dispatcher(PlugIn):
self.DEBUG('Invalid XML received from server. Forcing disconnect.', 'error') self.DEBUG('Invalid XML received from server. Forcing disconnect.', 'error')
self._owner.Connection.pollend() self._owner.Connection.pollend()
return 0 return 0
except ValueError, e:
self.DEBUG(str(e), 'error')
self._owner.Connection.pollend()
return 0
if len(self._pendingExceptions) > 0: if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop() _pendingException = self._pendingExceptions.pop()
raise _pendingException[0], _pendingException[1], _pendingException[2] raise _pendingException[0], _pendingException[1], _pendingException[2]

View File

@ -386,7 +386,11 @@ class NodeBuilder:
else: else:
self._document_attrs[attr] = val self._document_attrs[attr] = val
ns = self._document_nsp.get(nsp, 'http://www.gajim.org/xmlns/undeclared-root') 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: if not self.last_is_data and self._ptr.parent:
self._ptr.parent.data.append('') self._ptr.parent.data.append('')
self.last_is_data = 0 self.last_is_data = 0