diff --git a/src/jmc/jabber/component.py b/src/jmc/jabber/component.py index cd09fdd..678dbdf 100644 --- a/src/jmc/jabber/component.py +++ b/src/jmc/jabber/component.py @@ -199,7 +199,8 @@ class MailHandler(Handler): def filter(self, stanza, lang_class): """Return empty array if JID match '.*%.*@componentJID'""" - if self.dest_jid_regexp.match(stanza.get_to().node): + node = stanza.get_to().node + if node is not None and self.dest_jid_regexp.match(node): bare_from_jid = unicode(stanza.get_from().bare()) accounts = Account.select(Account.q.user_jid == bare_from_jid) if accounts.count() == 0: diff --git a/src/jmc/jabber/tests/component.py b/src/jmc/jabber/tests/component.py index fa49b69..58ec51e 100644 --- a/src/jmc/jabber/tests/component.py +++ b/src/jmc/jabber/tests/component.py @@ -692,6 +692,22 @@ class MailHandler_TestCase(unittest.TestCase): self.assertEquals(accounts[0].name, "account11") del account.hub.threadConnection + def test_filter_root(self): + account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL) + account11 = SMTPAccount(user_jid="user1@test.com", + name="account11", + jid="account11@jcl.test.com") + account11.default_account = True + account12 = SMTPAccount(user_jid="user1@test.com", + name="account12", + jid="account12@jcl.test.com") + message = Message(from_jid="user1@test.com", + to_jid="jcl.test.com", + body="message") + accounts = self.handler.filter(message, None) + self.assertEquals(accounts, None) + del account.hub.threadConnection + def test_filter_no_default(self): account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL) account11 = SMTPAccount(user_jid = "user1@test.com", \