Skip to content

Commit

Permalink
load report_store modules using Module::Load instead of relying on 'e…
Browse files Browse the repository at this point in the history
…val' (#237)
  • Loading branch information
bigio authored Jun 1, 2024
1 parent 6a830d0 commit 9588cc8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ my $module_build_args = {
"IO::Socket::SSL" => 0,
"IO::Uncompress::Gunzip" => 0,
"IO::Uncompress::Unzip" => 0,
"Module::Load" => 0,
"Net::DNS::Resolver" => 0,
"Net::IDN::Encode" => 0,
"Net::IP" => 0,
Expand Down
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ my %META = (
"IO::Socket::SSL" => 0,
"IO::Uncompress::Gunzip" => 0,
"IO::Uncompress::Unzip" => 0,
"Module::Load" => 0,
"Net::DNS::Resolver" => 0,
"Net::IDN::Encode" => 0,
"Net::IP" => 0,
Expand Down
5 changes: 3 additions & 2 deletions lib/Mail/DMARC/Report/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use Email::Simple;
use Encode;
use IO::Uncompress::Unzip;
use IO::Uncompress::Gunzip;
use Module::Load;
use XML::LibXML;

use parent 'Mail::DMARC::Base';
Expand All @@ -20,7 +21,7 @@ require Mail::DMARC::Report::Aggregate::Record;

sub from_imap {
my $self = shift;
eval "require Net::IMAP::Simple"; ## no critic (Eval)
load "Net::IMAP::Simple";
croak "Net::IMAP::Simple seems to not work, is it installed?" if $@;

my $server = $self->config->{imap}{server} or croak "no imap server conf";
Expand Down Expand Up @@ -112,7 +113,7 @@ sub from_mbox {

# TODO: replace this module
# commented out due to build test failures
# eval "require Mail::Mbox::MessageParser"; ## no critic (Eval)
# load "Mail::Mbox::MessageParser";
# croak "is Mail::Mbox::MessageParser installed?" if $@;

# my $file_handle = FileHandle->new($file_name);
Expand Down
3 changes: 2 additions & 1 deletion lib/Mail/DMARC/Report/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings;

use Carp;
use Module::Load;

use parent 'Mail::DMARC::Base';

Expand Down Expand Up @@ -40,7 +41,7 @@ sub backend {

return $self->{$backend} if ref $self->{$backend};
my $module = "Mail::DMARC::Report::Store::$backend";
eval "use $module"; ## no critic (Eval)
load $module;
if ($@) {
croak "Unable to load backend $backend: $@\n";
}
Expand Down

0 comments on commit 9588cc8

Please sign in to comment.