MailX/Qmail/Queue/Message.pm

filter: Statementstmt 36.1% 17 / 47 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 45.4% 5 / 11 Podpod 100% 5 / 5 totaltotal 31.0% 27 / 87 CC 10 SCAR 23.8
CC
10
Cov
25%
helo
20.0
replace_header
20.0
header
12.0
CRAP 10.8
« Mail/Qmail/Filter/LogEnvelope.pm ↑ Summary Mail/Qmail/Filter/RewriteFrom.pm »
1 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MailX::Qmail::Queue::Message;
5  
6 1 our $VERSION = '1.0';
7  
8 1 ▶use base 'Mail::Qmail::Queue::Message';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Mail::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Mail::Header;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Use inside-out attributes to avoid interference with base class:
14 1 my ( %header, %body );
15  
16 0 ▶sub header {
Subroutine header: not called CC=3 SCAR=24.8
Pod documented
17 0 my $self = shift;
18 0 ▶ return $header{$self} if exists $header{$self};
Branch: 1 branch
BranchTrueFalseTotal
if exists $header{$self} 0 0 0
19 0 ▶ open my $fh, '<', $self->body_ref or die 'Cannot read message';
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $self->body_ref or die "Cannot read message" 0 0 0
20 0 $header{$self} = Mail::Header->new($fh);
21 0 local $/;
22 0 $body{$self} = <$fh>;
23 0 $header{$self};
24 }
25  
26 0 ▶sub header_from {
Subroutine header_from: not called CC=2 SCAR=17.9
Pod documented
27 0 my $self = shift;
28 0 ▶ my $from = $self->header->get('From') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $from = $self->header->get("From") or return 0 0 0
29 0 ($from) = Mail::Address->parse($from);
30 0 $from;
31 }
32  
33 0 ▶sub helo {
Subroutine helo: not called CC=4 SCAR=30.0
Pod documented
34 0 my $header = shift->header;
35 0 ▶ my $received = $header->get('Received') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $received = $header->get("Received") or return 0 0 0
36 0 ▶ $received =~ /^from .*? \(HELO (.*?)\) /
Branch: 1 branch
BranchTrueFalseTotal
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u or return 0 0 0
Condition0%0/3
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u
$received =~ /^from .*? \(HELO (.*?)\) /u $received =~ /^from (\S+) \(/u
Truth table0%0/3
A or B
A= $received =~ /^from .*? \(HELO (.*?)\) /uB= $received =~ /^from (\S+) \(/u
ABresult
1X1
011
000
37 or $received =~ /^from (\S+) \(/
38 or return;
39 0 $1;
40 }
41  
42 0 ▶sub add_header {
Subroutine add_header: not called CC=1 SCAR=6.9
Pod documented
43 0 my $self = shift;
44 0 ${ $self->body_ref } = join "\n", @_, $self->body;
45 0 delete $header{$self};
46 0 $self;
47 }
48  
49 0 ▶sub replace_header {
Subroutine replace_header: not called CC=4 SCAR=30.0
Pod documented
50 0 my ( $self, $header ) = @_;
51 0 ▶ $self->header unless exists $body{$self}; # force parsing
Branch: 1 branch
BranchTrueFalseTotal
unless exists $body{$self} 0 0 0
52 0 ▶ $header = $header->as_string if ref $header && $header->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if ref $header and $header->can("as_string") 0 0 0
Condition0%0/3
ref $header and $header->can("as_string")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $header and $header->can("as_string")
ref $header $header->can("as_string")
Truth table0%0/3
A and B
A= ref $headerB= $header->can("as_string")
ABresult
0X0
100
111
53 0 ${ $self->body_ref } = join "\n", $header, $body{$self};
54 0 delete $header{$self};
55 0 $self;
56 }
57  
58 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
59 0 my $self = shift;
60 0 delete $header{$self};
61 0 delete $body{$self};
62 }
63  
64 1 1;
65  
66 __END__
« Mail/Qmail/Filter/LogEnvelope.pm ↑ Summary Mail/Qmail/Filter/RewriteFrom.pm »