Comments
Patch
@@ -286,3 +286,25 @@
If s is not a valid boolean, returns None.
"""
return _booleans.get(s.lower(), None)
+
+_correctauthorformat = remod.compile(br'^[^<]+\s\<[^<>]+@[^<>]+\>$')
+def isauthorwellformed(author):
+ '''Return True if the author field is well formed
+ (ie "Contributor Name <contrib@email.dom>")
+
+ >>> isauthorwellformed(b'Good Author <good@author.com>')
+ True
+ >>> isauthorwellformed(b'Author <good@author.com>')
+ True
+ >>> isauthorwellformed(b'Bad Author')
+ False
+ >>> isauthorwellformed(b'Bad Author <author@author.com')
+ False
+ >>> isauthorwellformed(b'Bad Author author@author.com')
+ False
+ >>> isauthorwellformed(b'<author@author.com>')
+ False
+ >>> isauthorwellformed(b'Bad Author <author>')
+ False
+ '''
+ return _correctauthorformat.match(author) is not None