From a6a967b2f0d57b858a3105ac445192bbada59552 Mon Sep 17 00:00:00 2001 From: souliane Date: Tue, 15 Dec 2015 13:30:47 +0100 Subject: [PATCH] complete the Exception's list when catching JID error: - Twisted JID constructor raises not only jid.InvalidFormat but also RuntimeError and AttributeError --- src/plugins/plugin_exp_command_export.py | 2 +- src/plugins/plugin_exp_parrot.py | 2 +- src/plugins/plugin_misc_text_commands.py | 2 +- src/plugins/plugin_xep_0045.py | 4 ++-- src/plugins/plugin_xep_0065.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/plugin_exp_command_export.py b/src/plugins/plugin_exp_command_export.py index 6e5e001f..0bc98746 100755 --- a/src/plugins/plugin_exp_command_export.py +++ b/src/plugins/plugin_exp_command_export.py @@ -151,7 +151,7 @@ class CommandExport(object): if not _jid.user or not _jid.host: raise jid.InvalidFormat _jid = _jid.userhostJID() - except (jid.InvalidFormat, RuntimeError): + except (RuntimeError, jid.InvalidFormat, AttributeError): log.info(u"invalid target ignored: %s" % (target,)) continue process_prot = ExportCommandProtocol(self, _jid, options, profile) diff --git a/src/plugins/plugin_exp_parrot.py b/src/plugins/plugin_exp_parrot.py index 2ed9250d..d8d454f5 100755 --- a/src/plugins/plugin_exp_parrot.py +++ b/src/plugins/plugin_exp_parrot.py @@ -139,7 +139,7 @@ class Exp_Parrot(object): link_left_jid = jid.JID(mess_data["unparsed"].strip()) if not link_left_jid.user or not link_left_jid.host: raise jid.InvalidFormat - except jid.InvalidFormat: + except (RuntimeError, jid.InvalidFormat, AttributeError): txt_cmd.feedBack("Can't activate Parrot mode for invalid jid", mess_data, profile) return False diff --git a/src/plugins/plugin_misc_text_commands.py b/src/plugins/plugin_misc_text_commands.py index ab6b46e5..3ef275d3 100755 --- a/src/plugins/plugin_misc_text_commands.py +++ b/src/plugins/plugin_misc_text_commands.py @@ -296,7 +296,7 @@ class TextCommands(object): target_jid = jid.JID(entity) if not target_jid.user or not target_jid.host: raise jid.InvalidFormat - except (jid.InvalidFormat, RuntimeError): + except (RuntimeError, jid.InvalidFormat, AttributeError): self.feedBack(_("Invalid jid, can't whois"), mess_data, profile) return False diff --git a/src/plugins/plugin_xep_0045.py b/src/plugins/plugin_xep_0045.py index 179a31df..0788e547 100755 --- a/src/plugins/plugin_xep_0045.py +++ b/src/plugins/plugin_xep_0045.py @@ -562,7 +562,7 @@ class XEP_0045(object): entity_jid = jid.JID(jid_s).userhostJID() assert(entity_jid.user) assert(entity_jid.host) - except (IndexError, jid.InvalidFormat, AssertionError): + except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError, AssertionError): feedback = _(u"You must provide a valid JID to ban, like in '/ban contact@example.net'") self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) return False @@ -594,7 +594,7 @@ class XEP_0045(object): entity_jid = jid.JID(jid_s).userhostJID() assert(entity_jid.user) assert(entity_jid.host) - except (IndexError, jid.InvalidFormat, AssertionError): + except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError, AssertionError): feedback = _(u"You must provide a valid JID to affiliate, like in '/affiliate contact@example.net member'") self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) return False diff --git a/src/plugins/plugin_xep_0065.py b/src/plugins/plugin_xep_0065.py index 7358e975..97621fa8 100755 --- a/src/plugins/plugin_xep_0065.py +++ b/src/plugins/plugin_xep_0065.py @@ -782,7 +782,7 @@ class XEP_0065(object): if not all((host, jid, port)): raise KeyError jid_ = jid.JID(jid_) - except (StopIteration, KeyError, RuntimeError, jid.InvalidFormat): + except (StopIteration, KeyError, RuntimeError, jid.InvalidFormat, AttributeError): log.warning(u"Invalid proxy data received from {}".format(proxy.full())) notFound(server)