repoze/repoze.postoffice — pull request #1 by ctheune (2013-04-18 10:58:34+00:00)
Title: Handle broken addresses in ToHostName filter more gracefully

We had a problem manifesting in this traceback:

Traceback (most recent call last):
File "bin/postoffice", line 111, in
repoze.postoffice.script.main()
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/script.py", line 75, in main
return ConsoleScript()()
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/script.py", line 48, in __call__
po.import_messages(self.log)
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/api.py", line 177, in import_messages
self._import_message(message, log)
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/api.py", line 220, in _import_message
if not filters or not _filters_match(filters, message):
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/api.py", line 396, in _filters_match
if not filter_(message):
File "/srv/multikarl/production/15/eggs/repoze.postoffice-0.21-py2.6.egg/repoze/postoffice/filters.py", line 28, in __call__
addr = addr[lt+1:addr.rindex('>')]
ValueError: substring not found

This stopped any incoming mail processing.

The attached patch fixes it by accepting anything after the "<" as the potential email address and avoids getting stuck.