Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting proper redirect syntax, namely redirect= #144

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions checkdmarc/spf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@

SPF_VERSION_TAG_REGEX_STRING = "v=spf1"
SPF_MECHANISM_REGEX_STRING = (
r"([+\-~?])?(mx|ip4|ip6|exists|include|all|a|redirect|exp|ptr)"
r"[:]?([\w+/_.:\-{%}]*)"
r"([+\-~?])?"
r"(mx:?|ip4:?|ip6:?|exists:?|include:?|all:?|a:?|redirect=|exp:?|ptr:?)"
r"([\w+/_.:\-{%}]*)"
)
AFTER_ALL_REGEX_STRING = r"\ball\s*[^\s]+"

Expand Down Expand Up @@ -276,7 +277,7 @@ def parse_spf_record(
lookup_mechanism_count = 0
void_lookup_mechanism_count = 0
for match in matches:
mechanism = match[1].lower()
mechanism = match[1].lower().strip(':=')
if mechanism in lookup_mechanisms:
lookup_mechanism_count += 1
if lookup_mechanism_count > 10:
Expand All @@ -288,7 +289,7 @@ def parse_spf_record(

for match in matches:
result = spf_qualifiers[match[0]]
mechanism = match[1]
mechanism = match[1].strip(':=')
value = match[2]

try:
Expand Down
Loading