Skip to content

Commit

Permalink
Fix SPF Record verification failing for domains with a label starting…
Browse files Browse the repository at this point in the history
… with "all" (#145)
  • Loading branch information
Maxime HUYGHE committed Sep 26, 2024
1 parent 39907ff commit 70a178e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions checkdmarc/spf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
r"(mx:?|ip4:?|ip6:?|exists:?|include:?|all:?|a:?|redirect=|exp:?|ptr:?)"
r"([\w+/_.:\-{%}]*)"
)
AFTER_ALL_REGEX_STRING = r"\ball\s*[^\s]+"
AFTER_ALL_REGEX_STRING = r"([\s^][+\-~?]?all)\s+[^\s]+"

SPF_MECHANISM_REGEX = re.compile(SPF_MECHANISM_REGEX_STRING, re.IGNORECASE)
AFTER_ALL_REGEX = re.compile(AFTER_ALL_REGEX_STRING, re.IGNORECASE)
Expand Down Expand Up @@ -253,7 +253,7 @@ def parse_spf_record(
f"{correct_record} not: {record}")
if len(AFTER_ALL_REGEX.findall(record)) > 0:
warnings.append("Any text after the all mechanism is ignored")
record = AFTER_ALL_REGEX.sub("all", record)
record = AFTER_ALL_REGEX.sub(r"\1", record)
parsed_record = spf_syntax_checker.parse(record)
if not parsed_record.is_valid:
pos = parsed_record.pos
Expand Down

0 comments on commit 70a178e

Please sign in to comment.