Skip to content

Commit

Permalink
Apply patch from RT#149825
Browse files Browse the repository at this point in the history
Fixes char_str_list is not a valid sub in new Net::DNS

Thanks to [email protected]
  • Loading branch information
marcbradshaw committed Nov 13, 2023
1 parent 30bb29f commit b3a6ebd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
21 changes: 19 additions & 2 deletions lib/Mail/SPF/Mod/Exp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Mail::SPF::Mod::Exp - SPF record C<exp> modifier class
use warnings;
use strict;

use Net::DNS;

use Mail::SPF::Mod;
use base 'Mail::SPF::GlobalMod';

Expand Down Expand Up @@ -145,12 +147,27 @@ 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
my $explanation = Mail::SPF::MacroString->new(

my $explanation;
# join with no intervening spaces, RFC 6376
if ( Net::DNS->VERSION >= 0.69 ) {
# must call txtdata() in a list context
$explanation = Mail::SPF::MacroString->new(
text => join('', $txt_rrs[0]->txtdata),
server => $server,
request => $request,
is_explanation => TRUE
);
} else {
# char_str_list method is 'historical'
$explanation = Mail::SPF::MacroString->new(
text => join('', $txt_rrs[0]->char_str_list),
server => $server,
request => $request,
is_explanation => TRUE
);
);
}

$request->state('authority_explanation', $explanation);
}
# Ignore DNS and other errors:
Expand Down
12 changes: 11 additions & 1 deletion lib/Mail/SPF/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use strict;
use base 'Mail::SPF::Base';

use Error ':try';
use Net::DNS;
use Net::DNS::Resolver;

use Mail::SPF::MacroString;
Expand Down Expand Up @@ -510,10 +511,19 @@ 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);
my $text;
# join with no intervening spaces, RFC 6376
if ( Net::DNS->VERSION >= 0.69 ) {
# must call txtdata() in a list context
$text = join '', $rr->txtdata;
} else {
# char_str_list method is 'historical'
$text = join('', $rr->char_str_list);
}
my $record;

# Try to parse RR as each of the requested record versions,
Expand Down

0 comments on commit b3a6ebd

Please sign in to comment.