don't match on empty lines (bug 763763)
This commit is contained in:
Родитель
aae4b960a4
Коммит
659e7e2a66
|
@ -23,6 +23,9 @@ class AccessWhitelist(amo.models.ModelBase):
|
|||
"""Loop through whitelist and find any matches."""
|
||||
for w in AccessWhitelist.objects.all():
|
||||
for e in w.email.replace('\r', '').split('\n'):
|
||||
e = e.strip()
|
||||
if not e:
|
||||
continue
|
||||
# Asterisks become .+ so that we can match wildcards.
|
||||
if re.match(re.escape(e).replace('\\*', '.+'), email):
|
||||
return True
|
||||
|
|
|
@ -249,3 +249,9 @@ class TestAccessWhitelist(amo.tests.TestCase):
|
|||
with self.assertNumQueries(1):
|
||||
# Exit post-save.
|
||||
AccessWhitelist.objects.create(email='')
|
||||
|
||||
def test_empty(self):
|
||||
for value in ['', ' ']:
|
||||
AccessWhitelist.objects.all().delete()
|
||||
AccessWhitelist.objects.create(email=value)
|
||||
eq_(AccessWhitelist.matches('any@email.com'), False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче