]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: Put more specific 'From' regex first
authorStephen Finucane <stephen.finucane@intel.com>
Thu, 14 Apr 2016 16:38:57 +0000 (17:38 +0100)
committerStephen Finucane <stephenfinucane@hotmail.com>
Fri, 2 Sep 2016 19:04:14 +0000 (20:04 +0100)
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>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
patchwork/parser.py
patchwork/tests/test_parser.py

index b5f2ed6fa0d6ba7fe31c64da4faa54e526693c97..41694ca345dbc28c144c286fa7eab9a5eee70eb0 100644 (file)
@@ -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]))),
     ]
index 684a6673604eaebe4c6e080d3fe2e2a4519c6a6f..02845fb82b4af31cea0e16aa4b1106e0de6f472a 100644 (file)
@@ -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