diff roundup/mailgw.py @ 4531:ddff9669361b

Fix matching of incoming email addresses to the alternate_addresses field... ...of a user -- this would match substrings, e.g. if the user has discuss-support@example.com as an alternate email and an incoming mail is addressed to support@example.com this would (wrongly) match. Note: I *think* I've seen this discussed somewhere but couldn't find it, neither in the tracker nor in recent discussions on the mailinglists. So if someone remembers an issue which now should be closed, please tell me :-)
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 24 Aug 2011 14:43:52 +0000
parents a00e0e73bb26
children c246f176e7bb
line wrap: on
line diff
--- a/roundup/mailgw.py	Thu Aug 11 19:21:26 2011 +0000
+++ b/roundup/mailgw.py	Wed Aug 24 14:43:52 2011 +0000
@@ -1666,7 +1666,17 @@
     props = db.user.getprops()
     if props.has_key('alternate_addresses'):
         users = db.user.filter(None, {'alternate_addresses': address})
-        user = extractUserFromList(db.user, users)
+        # We want an exact match of the email, not just a substring
+        # match. Otherwise e.g. support@example.com would match
+        # discuss-support@example.com which is not what we want.
+        found_users = []
+        for u in users:
+            alt = db.user.get(u, 'alternate_addresses').split('\n')
+            for a in alt:
+                if a.strip().lower() == address.lower():
+                    found_users.append(u)
+                    break
+        user = extractUserFromList(db.user, found_users)
         if user is not None:
             return user
 

Roundup Issue Tracker: http://roundup-tracker.org/