| 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.41'; | |||||||||||||||||||||||||||
| 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 add_header { | ||||||||||||||||||||||||||
|
Subroutine
add_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | 0 | ${ $self->body_ref } = join "\n", @_, $self->body; | |||||||||||||||||||||||||||
| 19 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 20 | 0 | $self; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub header { | ||||||||||||||||||||||||||
|
Subroutine
header: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | ▶ | return $header{$self} if exists $header{$self}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | open my $fh, '<', $self->body_ref or die 'Cannot read message'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | $header{$self} = Mail::Header->new($fh); | |||||||||||||||||||||||||||
| 28 | 0 | local $/; | |||||||||||||||||||||||||||
| 29 | 0 | $body{$self} = <$fh>; | |||||||||||||||||||||||||||
| 30 | 0 | $header{$self}; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub header_from { | ||||||||||||||||||||||||||
|
Subroutine
header_from: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $from = $self->header->get('From') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ($from) = Mail::Address->parse($from); | |||||||||||||||||||||||||||
| 37 | 0 | $from; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub helo { | ||||||||||||||||||||||||||
|
Subroutine
helo: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 0 | my $header = shift->header; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $received = $header->get('Received') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $received =~ /^from .*? \(HELO (.*?)\) / | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u
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
| |||||||||||||||||||||||||||||
| 44 | or $received =~ /^from (\S+) \(/ | ||||||||||||||||||||||||||||
| 45 | or return; | ||||||||||||||||||||||||||||
| 46 | 0 | $1; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub identity { | ||||||||||||||||||||||||||
|
Subroutine
identity: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | 0 | require Digest::SHA1; | |||||||||||||||||||||||||||
| 52 | 0 | my $digest = Digest::SHA1->new; | |||||||||||||||||||||||||||
| 53 | 0 | $digest->add( map "$_\n", $self->from, sort $self->to ); | |||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||
| 55 | # We only take some header lines for the hash, because tests showed | ||||||||||||||||||||||||||||
| 56 | # that others (e.g. Received, DKIM-Signatures etc.) _do_ change | ||||||||||||||||||||||||||||
| 57 | # between several delivery attempts of the same message. | ||||||||||||||||||||||||||||
| 58 | 0 | my $header = $self->header; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # I observed cases in the wild where the Date header line changed | ||||||||||||||||||||||||||||
| 61 | # between delivery attempts; therefore we do not include it in the | ||||||||||||||||||||||||||||
| 62 | # hash. And e.g. for AOL.com, even the Message-ID might change. | ||||||||||||||||||||||||||||
| 63 | 0 | for my $name (qw(From To Subject)) { | |||||||||||||||||||||||||||
| 64 | 0 | $digest->add( map "$name: $_", $header->get($name) ); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | $digest->add( "\n", $body{$self} ); | |||||||||||||||||||||||||||
| 68 | 0 | $digest->hexdigest; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub remote_host { | ||||||||||||||||||||||||||
|
Subroutine
remote_host: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | $ENV{TCPREMOTEHOST}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub remote_ip { | ||||||||||||||||||||||||||
|
Subroutine
remote_ip: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | $ENV{TCPREMOTEIP}; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub replace_header { | ||||||||||||||||||||||||||
|
Subroutine
replace_header: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | my ( $self, $header ) = @_; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->header unless exists $body{$self}; # force parsing | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $header = $header->as_string if ref $header && $header->can('as_string'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $header and $header->can("as_string")
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")
| |||||||||||||||||||||||||||||
| 83 | 0 | ${ $self->body_ref } = join "\n", $header, $body{$self}; | |||||||||||||||||||||||||||
| 84 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 85 | 0 | $self; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 91 | 0 | delete $body{$self}; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 1 | 1; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||||||||||