diff mbox

[05/11] parser: Put more specific 'From' regex first

Message ID 1468402860-3409-6-git-send-email-stephen.finucane@intel.com
State Superseded
Headers show

Commit Message

Stephen Finucane July 13, 2016, 9:40 a.m. UTC
Multiple different 'From:' header styles are supported by the parser,
but some of these are less specific than others. Attempt to parse using
a more specific style before going with the more generic one.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
 patchwork/parser.py            |    6 +++---
 patchwork/tests/test_parser.py |    1 -
 2 files changed, 3 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/patchwork/parser.py b/patchwork/parser.py
index 938b965..2ee12ca 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -111,13 +111,13 @@  def find_author(mail):
         # for "Firstname Lastname" <example@example.com> style addresses
         (re.compile(r'"?(.*?)"?\s*<([^>]+)>'), (lambda g: (g[0], g[1]))),
 
-        # for example@example.com (Firstname Lastname) style addresses
-        (re.compile(r'"?(.*?)"?\s*\(([^\)]+)\)'), (lambda g: (g[1], g[0]))),
-
         # for example at example.com (Firstname Lastname) style addresses
         (re.compile(r'(.*?)\sat\s(.*?)\s*\(([^\)]+)\)'),
          (lambda g: (g[2], '@'.join(g[0:2])))),
 
+        # for example@example.com (Firstname Lastname) style addresses
+        (re.compile(r'"?(.*?)"?\s*\(([^\)]+)\)'), (lambda g: (g[1], g[0]))),
+
         # everything else
         (re.compile(r'(.*)'), (lambda g: (None, g[0]))),
     ]
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index 684a667..02845fb 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -38,7 +38,6 @@  from patchwork.parser import find_pull_request
 from patchwork.parser import parse_mail as _parse_mail
 from patchwork.parser import parse_series_marker
 from patchwork.parser import split_prefixes
-from patchwork.tests.utils import create_email
 from patchwork.tests.utils import create_project
 from patchwork.tests.utils import create_state
 from patchwork.tests.utils import create_user