Skip to content
Snippets Groups Projects
Commit 50f0b798 authored by Jan Philipp Timme's avatar Jan Philipp Timme
Browse files

Fix bug that occurs with linebreaks within from header value

parent e538d99a
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,12 @@ split_from_regex = re.compile('(?P<from_label>.*)<(?P<from_address>.*)>$')
address_domain_regex = re.compile('.*@(?P<domain>[\.\w-]+)')
def normalizeRawFromHeader(value):
return value.replace('\n', '').replace('\r', '').strip()
def parseFromHeader(value):
"""Split 'From:' header into label and address values."""
"""Split 'From:'-header into label and address values."""
match = split_from_regex.match(value)
result = {
'label': match.group('from_label').strip(),
......@@ -59,7 +63,7 @@ class SuspiciousFrom(Milter.Base):
"""Header hook gets called for every header within the email processed."""
if field.lower() == 'from':
logger.debug(f"({self.id}) Got \"From:\" header raw value: '{value}'")
value = value.strip('\n').strip()
value = normalizeRawFromHeader(value)
if value == '':
logger.info(f"Got empty from header value! WTF! Skipping.")
return Milter.CONTINUE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment