| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Email::MIME::Attachment::Stripper; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | $Email::MIME::Attachment::Stripper::VERSION = '1.317'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ABSTRACT: strip the attachments from an email | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Email::MIME 1.861; # new(\$str) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Email::MIME::ContentType 1.016; # type/subtype | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | my ($class, $email, %attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | $email = Email::MIME->new($email) if (ref($email) || 'SCALAR') eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $email || 'SCALAR'
MC/DC0%0/1
ref $email || 'SCALAR'
ref $email
Truth table50%1/2
A
A= ref $email
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | croak "Need a message" unless ref($email) || do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $email or do {
require Email::Abstract;
$email = "Email::Abstract"->cast($email, "Email::MIME")
}
MC/DC0%0/2
ref $email or do {
require Email::Abstract;
$email = "Email::Abstract"->cast($email, "Email::MIME")
}
ref $email
do {
require Email::Abstract;
$email = "Email::Abstract"->cast($email, "Email::MIME")
}
Truth table33%1/3
A or B
A= ref $emailB= do {
require Email::Abstract;
$email = "Email::Abstract"->cast($email, "Email::MIME")
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | require Email::Abstract; | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $email = Email::Abstract->cast($email, 'Email::MIME'); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | bless { message => $email, attr => \%attr }, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | sub message { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | $self->_detach_all unless exists $self->{attach}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 7 | return $self->{message}; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | ▶ | sub attachments { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attachments: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | $self->_detach_all unless exists $self->{attach}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | return $self->{attach} ? @{ $self->{attach} } : (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 11 | ▶ | sub _detach_all { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detach_all: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 11 | my ($self, $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 11 | ▶ | $part ||= $self->{message}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$part ||= $self->{"message"}
MC/DC0%0/2
$part ||= $self->{"message"}
$part
$self->{"message"}
Truth table66%2/3
A ||= B
A= $partB= $self->{"message"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 11 | ▶ | return if $part->parts == 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | my @attach = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | my @keep = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | foreach ( $part->parts ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 18 | ▶ | my $ct = $_->content_type || 'text/plain'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->content_type || 'text/plain'
MC/DC0%0/1
$_->content_type || 'text/plain'
$_->content_type
Truth table50%1/2
A
A= $_->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 18 | ▶ | my $dp = $_->header('Content-Disposition') || 'inline'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->header('Content-Disposition') || 'inline'
MC/DC100%1/1
$_->header('Content-Disposition') || 'inline'
$_->header('Content-Disposition')
Truth table100%2/2
A
A= $_->header('Content-Disposition')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 18 | ▶ | push(@keep, $_) and next | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
$ct =~ m[text/plain]i && $dp =~ /inline/i && (push(@keep, $_) && (next))
$ct =~ m[text/plain]i and $dp =~ /inline/i
push @keep, $_ and next
MC/DC0%0/3
$ct =~ m[text/plain]i && $dp =~ /inline/i && (push(@keep, $_) && (next))
$ct =~ m[text/plain]i
$dp =~ /inline/i
push @keep, $_
Truth table50%2/4
A and B && C
A= $ct =~ m[text/plain]iB= $dp =~ /inline/iC= push @keep, $_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | if $ct =~ m[text/plain]i && $dp =~ /inline/i; | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | push @attach, $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | ▶ | if ($_->parts > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my @kept=$self->_detach_all($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | push(@keep,@kept) if @kept; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | $part->parts_set(\@keep); | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 7 | push @{$self->{attach}}, map {; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 12 | my $content_type = parse_content_type($_->content_type); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | ▶ | content_type => join('/', @{$content_type}{qw[type subtype]}), | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$_->filename or ""
MC/DC100%1/1
$_->filename or ""
$_->filename
Truth table100%2/2
A
A= $_->filename
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | payload => $_->body, | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | filename => $self->{attr}->{force_filename} | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 12 | ? $_->filename(1) | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | : ($_->filename || ''), | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } @attach; | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 7 | return @keep; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||