diff --git a/lib/Mail/SPF/Mod/Exp.pm b/lib/Mail/SPF/Mod/Exp.pm index 50ca729..21ce984 100644 --- a/lib/Mail/SPF/Mod/Exp.pm +++ b/lib/Mail/SPF/Mod/Exp.pm @@ -145,12 +145,21 @@ sub process { @txt_rrs == 1 or $server->throw_result('permerror', $request, "Redundant authority explanation strings found at domain '$exp_domain'"); # RFC 4408, 6.2/4 + + # char_str_list method is 'historical', use as a fallback for Net::DNS prior to 0.69 + # where txtdata is not available. + # join with no intervening spaces, RFC 6376 + # must call txtdata() in a list context + my $text = $txt_rrs[0]->can('txtdata') + ? join('', $txt_rrs[0]->txtdata) + : join('', $txt_rrs[0]->char_str_list); my $explanation = Mail::SPF::MacroString->new( - text => join('', $txt_rrs[0]->char_str_list), - server => $server, - request => $request, - is_explanation => TRUE + text => $text, + server => $server, + request => $request, + is_explanation => TRUE ); + $request->state('authority_explanation', $explanation); } # Ignore DNS and other errors: diff --git a/lib/Mail/SPF/Server.pm b/lib/Mail/SPF/Server.pm index 8c360a5..e1a6b03 100644 --- a/lib/Mail/SPF/Server.pm +++ b/lib/Mail/SPF/Server.pm @@ -510,10 +510,17 @@ sub get_acceptable_records_from_packet { # (This may be too simplistic for future revisions of SPF.) my @records; + foreach my $rr ($packet->answer) { next if $rr->type ne $rr_type; # Ignore RRs of unexpected type. - my $text = join('', $rr->char_str_list); + # char_str_list method is 'historical', use as a fallback for Net::DNS prior to 0.69 + # where txtdata is not available. + # join with no intervening spaces, RFC 6376 + # must call txtdata() in a list context + my $text = $rr->can('txtdata') + ? join('', $rr->txtdata) + : join('', $rr->char_str_list); my $record; # Try to parse RR as each of the requested record versions,