diff --git a/checkdmarc/spf.py b/checkdmarc/spf.py index dcaaec9..38a3579 100644 --- a/checkdmarc/spf.py +++ b/checkdmarc/spf.py @@ -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]+" @@ -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: @@ -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: