From c703e1cb6451ed5053ddfd2698ff1f55273609e5 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 28 Feb 2020 17:58:57 +0100 Subject: [PATCH] Add Another InvalidHeaderDefect When an email header address field contains a period directly before the angle bracket, the default header policy raises an Attribute error, rather than adding a header defect. https://github.com/GOVCERT-LU/eml_parser/issues/41 --- Lib/email/_header_value_parser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index 9c55ef7fb453be..212d60e2c42350 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -1419,6 +1419,10 @@ def get_phrase(value): phrase.defects.append(errors.ObsoleteHeaderDefect( "period in 'phrase'")) value = value[1:] + if value[0] in PHRASE_ENDS: + value = " " + value + phrase.defects.append(errors.InvalidHeaderDefect( + "trailing period in 'phrase' with no CFWS")) else: try: token, value = get_word(value)