Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
92a9c5d9 by Philipp Hörist at 2019-10-11T16:45:00Z
Muclumbus: Catch additional exception on http result
- - - - -
64b8f9b7 by Philipp Hörist at 2019-10-11T20:19:05Z
Don't fail on invalid JIDs
Fixes #85
- - - - -
2 changed files:
- nbxmpp/dispatcher.py
- nbxmpp/modules/muclumbus.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -33,6 +33,7 @@ from nbxmpp.protocol import NS_STREAMS
from nbxmpp.protocol import NS_HTTP_BIND
from nbxmpp.protocol import NodeProcessed
from nbxmpp.protocol import InvalidFrom
+from nbxmpp.protocol import InvalidJid
from nbxmpp.protocol import InvalidStanza
from nbxmpp.protocol import Iq
from nbxmpp.protocol import Presence
@@ -533,7 +534,12 @@ class XMPPDispatcher(PlugIn):
log.debug('Got %s / %s stanza', xmlns, name)
# Convert simplexml to Protocol object
- stanza = self.handlers[xmlns][name]['type'](node=stanza)
+ try:
+ stanza = self.handlers[xmlns][name]['type'](node=stanza)
+ except InvalidJid:
+ log.warning('Invalid JID, ignoring stanza')
+ log.warning(stanza)
+ return
own_jid = self._owner.get_bound_jid()
properties = get_properties_struct(name)
@@ -561,8 +567,9 @@ class XMPPDispatcher(PlugIn):
# Unwrap carbon
try:
stanza, properties.carbon = unwrap_carbon(stanza, own_jid)
- except InvalidFrom as exc:
+ except (InvalidFrom, InvalidJid) as exc:
log.warning(exc)
+ log.warning(stanza)
return
except NodeProcessed as exc:
log.info(exc)
@@ -571,7 +578,9 @@ class XMPPDispatcher(PlugIn):
# Unwrap mam
try:
stanza, properties.mam = unwrap_mam(stanza, own_jid)
- except InvalidStanza:
+ except (InvalidStanza, InvalidJid) as exc:
+ log.warning(exc)
+ log.warning(stanza)
return
typ = stanza.getType()
=====================================
nbxmpp/modules/muclumbus.py
=====================================
@@ -188,7 +188,7 @@ class Muclumbus:
for item in items:
try:
anonymity_mode = AnonymityMode(item['anonymity_mode'])
- except ValueError:
+ except (ValueError, KeyError):
anonymity_mode = AnonymityMode.UNKNOWN
results.append(
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/9126550bdb60bee275c98c87ac4b2b0e5befd5c8...64b8f9b754610ac1f6e8c8f55f0a117bfaa4ffcf
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/9126550bdb60bee275c98c87ac4b2b0e5befd5c8...64b8f9b754610ac1f6e8c8f55f0a117bfaa4ffcf
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits