diff options
author | David Rousselie <dax@happycoders.org> | 2007-06-05 23:42:40 +0400 |
---|---|---|
committer | David Rousselie <dax@happycoders.org> | 2007-06-05 23:42:40 +0400 |
commit | 383370fa2294d9e02909db9a0b3ab207a41b8a0c (patch) | |
tree | 74b6158e8aff895d800b590a0be18afe2b1709e8 /src/jmc | |
parent | 9a4fb057ddc10e94bd7b3a1964ef36937ae52b5e (diff) |
filter root component JID in MailHandler
darcs-hash:20070605194240-86b55-3eac72f253c5b012c713dcc38812452d1d870111.gz
Diffstat (limited to 'src/jmc')
-rw-r--r-- | src/jmc/jabber/component.py | 3 | ||||
-rw-r--r-- | src/jmc/jabber/tests/component.py | 16 |
2 files changed, 18 insertions, 1 deletions
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", \ |