aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patchwork/parser.py7
-rw-r--r--patchwork/tests/test_parser.py23
2 files changed, 30 insertions, 0 deletions
diff --git a/patchwork/parser.py b/patchwork/parser.py
index a09fd75..dce03a4 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -373,6 +373,13 @@ def get_original_sender(mail, name, email):
# Mailman uses the format "<name> via <list>"
# Google Groups uses "'<name>' via <list>"
stripped_name = name[:name.rfind(' via ')].strip().strip("'")
+ elif name.endswith(' via'):
+ # Sometimes this seems to happen (perhaps if Mailman isn't set up with
+ # any list name)
+ stripped_name = name[:name.rfind(' via')].strip().strip("'")
+ else:
+ # We've hit a format that we don't expect
+ stripped_name = None
original_from = clean_header(mail.get('X-Original-From', ''))
if original_from:
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index f5631be..a60eb6b 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -366,6 +366,29 @@ class SenderCorrelationTest(TestCase):
self.assertEqual(person_b._state.adding, False)
self.assertEqual(person_b.id, person_a.id)
+ def test_weird_dmarc_munging(self):
+ project = create_project()
+ real_sender = 'Existing Sender <existing@example.com>'
+ munged_sender1 = "'Existing Sender' via <{}>".format(project.listemail)
+ munged_sender2 = "'Existing Sender' <{}>".format(project.listemail)
+
+ # Unmunged author
+ mail = self._create_email(real_sender)
+ person_a = get_or_create_author(mail, project)
+ person_a.save()
+
+ # Munged with no list name
+ mail = self._create_email(munged_sender1, None, None, real_sender)
+ person_b = get_or_create_author(mail, project)
+ self.assertEqual(person_b._state.adding, False)
+ self.assertEqual(person_b.id, person_a.id)
+
+ # Munged with no 'via'
+ mail = self._create_email(munged_sender2, None, None, real_sender)
+ person_b = get_or_create_author(mail, project)
+ self.assertEqual(person_b._state.adding, False)
+ self.assertEqual(person_b.id, person_a.id)
+
class SeriesCorrelationTest(TestCase):
"""Validate correct behavior of find_series."""