Skip to content

Commit f14b38b

Browse files
author
Ralf Schlatterbeck
committed
Fix matching of incoming email addresses to the alternate_addresses field...
...of a user -- this would match substrings, e.g. if the user has [email protected] as an alternate email and an incoming mail is addressed to [email protected] 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 :-)
1 parent c8c4d17 commit f14b38b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

CHANGES.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ Entries without name were done by Richard Jones.
88
Features:
99
Fixed:
1010

11-
issue2550715: IndexError when requesting non-existing file via http.
11+
- issue2550715: IndexError when requesting non-existing file via http.
1212
Reported and fixed by C�dric Krier. (Bernhard)
13-
14-
issue2550695: 'No sort or group' settings not retained when editing queries.
13+
- issue2550695: 'No sort or group' settings not retained when editing queries.
1514
Reported and fixed by John Kristensen. Tested by Satchidanand Haridas.
1615
(Bernhard)
16+
- Fix matching of incoming email addresses to the alternate_addresses
17+
field of a user -- this would match substrings, e.g. if the user has
18+
[email protected] as an alternate email and an incoming mail
19+
is addressed to [email protected] this would (wrongly) match. (Ralf)
1720

1821
2011-07-15 1.4.19 (r4638)
1922

roundup/mailgw.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,17 @@ def uidFromAddress(db, address, create=1, **user_props):
16661666
props = db.user.getprops()
16671667
if props.has_key('alternate_addresses'):
16681668
users = db.user.filter(None, {'alternate_addresses': address})
1669-
user = extractUserFromList(db.user, users)
1669+
# We want an exact match of the email, not just a substring
1670+
# match. Otherwise e.g. [email protected] would match
1671+
# [email protected] which is not what we want.
1672+
found_users = []
1673+
for u in users:
1674+
alt = db.user.get(u, 'alternate_addresses').split('\n')
1675+
for a in alt:
1676+
if a.strip().lower() == address.lower():
1677+
found_users.append(u)
1678+
break
1679+
user = extractUserFromList(db.user, found_users)
16701680
if user is not None:
16711681
return user
16721682

test/test_mailgw.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,12 @@ def testUserAlternateLookup(self):
22052205
self.assertEqual(uidFromAddress(self.db, ('', '[email protected]'), 0), i)
22062206
self.assertEqual(uidFromAddress(self.db, ('', '[email protected]'), 0), i)
22072207

2208+
def testUserAlternateSubstringNomatch(self):
2209+
i = self.db.user.create(username='user1', address='[email protected]',
2210+
alternate_addresses='[email protected]')
2211+
self.assertEqual(uidFromAddress(self.db, ('', '[email protected]'), 0), 0)
2212+
self.assertEqual(uidFromAddress(self.db, ('', '[email protected]'), 0), 0)
2213+
22082214
def testUserCreate(self):
22092215
i = uidFromAddress(self.db, ('', '[email protected]'), 1)
22102216
self.assertNotEqual(uidFromAddress(self.db, ('', '[email protected]'), 1), i)

0 commit comments

Comments
 (0)