Subject: | Improper handling of SPF records with embedded newlines |
Date: | Tue, 03 Sep 2013 11:44:23 -0500 |
To: | bug-Mail-SPF [...] rt.cpan.org |
From: | Jonathan Hall <jhall [...] efolder.net> |
Occasionally one will encounter an SPF record with an embedded newline.
Experience shows this is most common in include records. Examples (with
" marks around the text portion, to make newlines more apparent).
directadvantage.com. 3600 IN TXT "v=spf1 a mx
a:sue.directadvantage.com include:postalproducts.com ~all"
postalproducts.com. 86400 IN TXT "v=spf1 a mx
mx:mail.postalproducts.com mx:po2.postalproducts.com
mx:post.postalproducts.com
~all"
And:
rtdquality.us. 100 IN TXT "v=spf1
include:_incspfcheck.mailspike.net ?all"
_incspfcheck.mailspike.net. 100 IN TXT "v=spf1
exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}.spfcheck.mailspike.net ?all
"
When this happens, Mail::SPF generates an invalid Received header, such as:
Received-SPF: permerror (rtdquality.us ... _incspfcheck.mailspike.net:
Junk encountered in record 'v=spf1
exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}.spfcheck.mailspike.net ?all
') receiver=doublecheck.co.douglas.nv.us; identity=mailfrom;
envelope-from="edwin590@rtdquality.us"; helo=rtdquality.us;
client-ip=212.126.98.234
This header causes Mail::Header to complain, as there is no space after
the newline.
Possible solutions:
- Strip the newline(s) in the DNS resolver.
- Strip the newline(s) in the output headers
- Add a space after the newline in the headers (This would make the
header 'valid' again, but seems sloppy, as the newlines are rather
arbitrary)
- Raise an error?