xmlstream: prevent stanza parsing from crashing the whole thing

If an error happened while parsing a stanza, it would bring the whole
program down and disconnect instead of logging an error. And the DEBUG
log happened afterwards (so, never).
This commit is contained in:
mathieui 2024-12-14 15:52:51 +01:00
parent 23544731ef
commit 3d0b09e2e2

View File

@ -1414,7 +1414,11 @@ class XMLStream(asyncio.BaseProtocol):
# Convert the raw XML object into a stanza object. If no registered
# stanza type applies, a generic StanzaBase stanza will be used.
stanza: Optional[StanzaBase] = self._build_stanza(xml)
try:
stanza: Optional[StanzaBase] = self._build_stanza(xml)
except Exception as exc:
log.exception("Unable to parse stanza: %s,\n%s", exc, xml)
stanza = None
for filter in self.__filters['in']:
if stanza is not None:
filter = cast(SyncFilter, filter)