Handle case where DKIM record is split into several pieces

This commit is contained in:
Alexandre Aubin 2021-01-21 16:25:58 +01:00
parent 02ed684f9a
commit c8a23f26bb

View file

@ -130,8 +130,11 @@ class DNSRecordsDiagnoser(Diagnoser):
# Split expected/current # Split expected/current
# from "v=DKIM1; k=rsa; p=hugekey;" # from "v=DKIM1; k=rsa; p=hugekey;"
# to a set like {'v=DKIM1', 'k=rsa', 'p=...'} # to a set like {'v=DKIM1', 'k=rsa', 'p=...'}
# Additionally, for DKIM, because the key is pretty long,
# some DNS registrar sometime split it into several pieces like this:
# "p=foo" "bar" (with a space and quotes in the middle)...
expected = set(r["value"].strip(';" ').replace(";", " ").split()) expected = set(r["value"].strip(';" ').replace(";", " ").split())
current = set(r["current"].strip(';" ').replace(";", " ").split()) current = set(r["current"].replace('" "', '').strip(';" ').replace(";", " ").split())
# For SPF, ignore parts starting by ip4: or ip6: # For SPF, ignore parts starting by ip4: or ip6:
if r["name"] == "@": if r["name"] == "@":