| 1 | # Copyrights 1995-2024 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of the bundle MailTools. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md for Copyright. | ||||||||||||||||||||||||||||||||||||||
| 7 | # Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Internet;{ | ||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '2.22'; | |||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | # use warnings? probably breaking too much code | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Mail::Header; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Mail::Util qw/mailaddress/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Mail::Address; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | sub new(@) | ||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | { my $call = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=33.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | my $arg = @_ % 2 ? shift : undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 25 | 3 | my %opt = @_; | |||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | my $class = ref($call) || $call; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $call || $call
MC/DC0%0/2
ref $call || $call
ref $call
$call
Truth table33%1/3
A || B
A= ref $callB= $call
| |||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | $self->{mail_inet_head} = $opt{Header} if exists $opt{Header}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | $self->{mail_inet_body} = $opt{Body} if exists $opt{Body}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | 3 | my $head = $self->head; | |||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | $head->fold_length(delete $opt{FoldLength} || 79); | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{'FoldLength'} || 79
MC/DC0%0/1
delete $opt{'FoldLength'} || 79
delete $opt{'FoldLength'}
Truth table50%1/2
A
A= delete $opt{'FoldLength'}
| |||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | $head->mail_from($opt{MailFrom}) if exists $opt{MailFrom}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | $head->modify(exists $opt{Modify} ? $opt{Modify} : 1); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | if(!defined $arg) { } | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 39 | elsif(ref($arg) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | { $self->header($arg) unless exists $opt{Header}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | $self->body($arg) unless exists $opt{Body}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||
| 43 | elsif(defined fileno($arg)) | ||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { $self->read_header($arg) unless exists $opt{Header}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $self->read_body($arg) unless exists $opt{Body}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||
| 47 | else | ||||||||||||||||||||||||||||||||||||||
| 48 | 0 | { croak "couldn't understand $arg to Mail::Internet constructor"; | |||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 3 | $self; | |||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | sub read(@) | ||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $self->read_header(@_); | |||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->read_body(@_); | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | sub read_body($) | ||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | { my ($self, $fd) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
read_body: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->body( [ <$fd> ] ); | |||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | sub read_header(@) | ||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
read_header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $head->read(@_); | |||||||||||||||||||||||||||||||||||||
| 69 | 0 | $head->header; | |||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | sub extract($) | ||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | { my ($self, $lines) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
extract: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->head->extract($lines); | |||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->body($lines); | |||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | sub dup() | ||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
dup: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 82 | 2 | my $dup = ref($self)->new; | |||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | my $body = $self->{mail_inet_body} || []; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'mail_inet_body'} || []
MC/DC0%0/1
$self->{'mail_inet_body'} || []
$self->{'mail_inet_body'}
Truth table50%1/2
A
A= $self->{'mail_inet_body'}
| |||||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $head = $self->{mail_inet_head};; | |||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | 2 | $dup->{mail_inet_body} = [ @$body ]; | |||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | $dup->{mail_inet_head} = $head->dup if $head; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $dup; | |||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||
| 92 | #--------------- | ||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | sub body(;$@) | ||||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | 7 | ▶ | return $self->{mail_inet_body} ||= [] | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"mail_inet_body"} ||= []
MC/DC0%0/1
$self->{"mail_inet_body"} ||= []
$self->{"mail_inet_body"}
Truth table50%1/2
A
A= $self->{"mail_inet_body"}
| |||||||||||||||||||||||||||||||||||||||
| 98 | unless @_; | ||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | $self->{mail_inet_body} = ref $_[0] eq 'ARRAY' ? $_[0] : [ @_ ]; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 10 | ▶ | sub head { shift->{mail_inet_head} ||= Mail::Header->new } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
head: called CC=2 SCAR=7.2
Pod
documented
Condition66%2/3
+(shift())->{"mail_inet_head"} ||= "Mail::Header"->new
MC/DC0%0/2
+(shift())->{"mail_inet_head"} ||= "Mail::Header"->new
+(shift())->{"mail_inet_head"}
"Mail::Header"->new
Truth table66%2/3
A ||= B
A= +(shift())->{"mail_inet_head"}B= "Mail::Header"->new
| |||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||
| 106 | #--------------- | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | sub print($) | ||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my $fd = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || \*STDOUT
MC/DC0%0/1
shift() || \*STDOUT
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $self->print_header($fd) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->print_header($fd) and print $fd "\n"
MC/DC0%0/2
$self->print_header($fd) and print $fd "\n"
$self->print_header($fd)
print $fd "\n"
Truth table0%0/3
A and B
A= $self->print_header($fd)B= print $fd "\n"
| |||||||||||||||||||||||||||||||||||||||
| 113 | and print $fd "\n" | ||||||||||||||||||||||||||||||||||||||
| 114 | and $self->print_body($fd); | ||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub print_header($) { shift->head->print(@_) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
print_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | sub print_body($) | ||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
print_body: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $fd = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || \*STDOUT
MC/DC0%0/1
shift() || \*STDOUT
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | 0 | foreach my $ln (@{$self->body}) | |||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | { print $fd $ln or return 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||
| 128 | 0 | 1; | |||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | sub as_string() | ||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 134 | 4 | $self->head->as_string . "\n" . join '', @{$self->body}; | |||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | sub as_mbox_string($) | ||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | { my $self = shift->dup; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
as_mbox_string: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $escaped = shift; | |||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $self->head->delete('Content-Length'); | |||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | $self->escape_from unless $escaped; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 144 | 2 | $self->as_string . "\n"; | |||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||
| 147 | #--------------- | ||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | sub header { shift->head->header(@_) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub fold { shift->head->fold(@_) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
fold: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub fold_length { shift->head->fold_length(@_) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
fold_length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub combine { shift->head->combine(@_) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
combine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||
| 155 | sub add(@) | ||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | while(@_) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | 0 | { my ($tag, $line) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $ret = $head->add($tag, $line, -1) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 161 | or return undef; | ||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $ret; | |||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | sub replace(@) | ||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
replace: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | while(@_) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 173 | 0 | { my ($tag, $line) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $ret = $head->replace($tag, $line, 0) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 175 | or return undef; | ||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $ret; | |||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||
| 182 | sub get(@) | ||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return map { $head->get($_) } @_ | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 186 | if wantarray; | ||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||
| 188 | 0 | foreach my $tag (@_) | |||||||||||||||||||||||||||||||||||||
| 189 | 0 | { my $r = $head->get($tag); | |||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return $r if defined $r; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||
| 193 | 0 | undef; | |||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | sub delete(@) | ||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 199 | 0 | map { $head->delete($_) } @_; | |||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||
| 202 | # Undocumented; unused??? | ||||||||||||||||||||||||||||||||||||||
| 203 | sub empty() | ||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 205 | 0 | %$self = (); | |||||||||||||||||||||||||||||||||||||
| 206 | 0 | 1; | |||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||
| 209 | #--------------- | ||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||
| 211 | sub remove_sig($) | ||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | { my $body = shift->body; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_sig: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my $nlines = shift || 10; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 10
MC/DC0%0/1
shift() || 10
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $start = @$body; | |||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | while($i++ < $nlines && $start--) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$i++ < $nlines and $start--
MC/DC0%0/2
$i++ < $nlines and $start--
$i++ < $nlines
$start--
Truth table0%0/3
A and B
A= $i++ < $nlinesB= $start--
| |||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | { next if $body->[$start] !~ /^--[ ]?[\r\n]/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | 0 | splice @$body, $start, $i; | |||||||||||||||||||||||||||||||||||||
| 221 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||
| 226 | sub sign(@) | ||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | { my ($self, %arg) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sign: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($sig, @sig); | |||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if($sig = delete $arg{File}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 231 | 0 | { local *SIG; | |||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if(open(SIG, $sig)) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 234 | 0 | { local $_; | |||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | while(<SIG>) { last unless /^(--)?\s*$/ } | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 236 | 0 | @sig = ($_, <SIG>, "\n"); | |||||||||||||||||||||||||||||||||||||
| 237 | 0 | close SIG; | |||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | elsif($sig = delete $arg{Signature}) | ||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | { @sig = ref($sig) ? @$sig : split(/\n/, $sig); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if(@sig) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 245 | 0 | { $self->remove_sig; | |||||||||||||||||||||||||||||||||||||
| 246 | 0 | s/[\r\n]*$/\n/ for @sig; | |||||||||||||||||||||||||||||||||||||
| 247 | 0 | push @{$self->body}, "-- \n", @sig; | |||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self; | |||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||
| 254 | sub tidy_body() | ||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | { my $body = shift->body; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
tidy_body: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | shift @$body while @$body && $body->[0] =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$body and $body->[0] =~ /^\s*$/
MC/DC0%0/2
@$body and $body->[0] =~ /^\s*$/
@$body
$body->[0] =~ /^\s*$/
Truth table0%0/3
A and B
A= @$bodyB= $body->[0] =~ /^\s*$/
| |||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | pop @$body while @$body && $body->[-1] =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$body and $body->[-1] =~ /^\s*$/
MC/DC0%0/2
@$body and $body->[-1] =~ /^\s*$/
@$body
$body->[-1] =~ /^\s*$/
Truth table0%0/3
A and B
A= @$bodyB= $body->[-1] =~ /^\s*$/
| |||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $body; | |||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||
| 262 | #--------------- | ||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | sub reply(@) | ||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | { my ($self, %arg) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
reply: not called CC=40 SCAR=74.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $class = ref $self; | |||||||||||||||||||||||||||||||||||||
| 267 | 0 | my @reply; | |||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||
| 269 | 0 | local *MAILHDR; | |||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if(open(MAILHDR, "$ENV{HOME}/.mailhdr")) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 271 | { # User has defined a mail header template | ||||||||||||||||||||||||||||||||||||||
| 272 | 0 | @reply = <MAILHDR>; | |||||||||||||||||||||||||||||||||||||
| 273 | 0 | close MAILHDR; | |||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $reply = $class->new(\@reply); | |||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||
| 278 | # The Subject line | ||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $subject = $self->get('Subject') || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get('Subject') || ''
MC/DC0%0/1
$self->get('Subject') || ''
$self->get('Subject')
Truth table0%0/2
A
A= $self->get('Subject')
| |||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $subject = "Re: " . $subject | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$subject =~ /\S+/ and not $subject =~ /Re:/i
MC/DC0%0/2
$subject =~ /\S+/ and not $subject =~ /Re:/i
$subject =~ /\S+/
not $subject =~ /Re:/i
Truth table0%0/3
A and not(B)
A= $subject =~ /\S+/B= not $subject =~ /Re:/i
| |||||||||||||||||||||||||||||||||||||||
| 281 | if $subject =~ /\S+/ && $subject !~ /Re:/i; | ||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $reply->replace(Subject => $subject); | |||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||
| 285 | # Locate who we are sending to | ||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | my $to = $self->get('Reply-To') | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$self->get('Reply-To') || $self->get('From') || $self->get('Return-Path') || ''
$self->get("Reply-To") or $self->get("From") or $self->get("Return-Path")
$self->get("Reply-To") or $self->get("From")
MC/DC0%0/3
$self->get('Reply-To') || $self->get('From') || $self->get('Return-Path') || ''
$self->get("Reply-To")
$self->get("From")
$self->get("Return-Path")
Truth table0%0/4
A or B or C
A= $self->get("Reply-To")B= $self->get("From")C= $self->get("Return-Path")
| |||||||||||||||||||||||||||||||||||||||
| 287 | || $self->get('From') | ||||||||||||||||||||||||||||||||||||||
| 288 | || $self->get('Return-Path') | ||||||||||||||||||||||||||||||||||||||
| 289 | || ""; | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $sender = (Mail::Address->parse($to))[0]; | |||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $name = $sender->name; | |||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | unless(defined $name) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 295 | 0 | { my $fr = $self->get('From'); | |||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $fr = (Mail::Address->parse($fr))[0] if defined $fr; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $name = $fr->name if defined $fr; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | my $indent = $arg{Indent} || ">"; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg{'Indent'} || '>'
MC/DC0%0/1
$arg{'Indent'} || '>'
$arg{'Indent'}
Truth table0%0/2
A
A= $arg{'Indent'}
| |||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if($indent =~ /\%/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 302 | 0 | { my %hash = ( '%' => '%'); | |||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | my @name = $name ? grep( {length $_} split /[\n\s]+/, $name) : ''; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $hash{f} = $name[0]; | |||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $hash{F} = $#name ? substr($hash{f},0,1) : $hash{f}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $hash{l} = $#name ? $name[$#name] : ""; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $hash{L} = substr($hash{l},0,1) || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
substr($hash{'l'}, 0, 1) || ''
MC/DC0%0/1
substr($hash{'l'}, 0, 1) || ''
substr($hash{'l'}, 0, 1)
Truth table0%0/2
A
A= substr($hash{'l'}, 0, 1)
| |||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $hash{n} = $name || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name || ''
MC/DC0%0/1
$name || ''
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $hash{I} = join "", map {substr($_,0,1)} @name; | |||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $indent =~ s/\%(.)/defined $hash{$1} ? $hash{$1} : $1/eg; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $id = $sender->address; | |||||||||||||||||||||||||||||||||||||
| 318 | 0 | $reply->replace(To => $id); | |||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | # Find addresses not to include | ||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my $mailaddresses = $ENV{MAILADDRESSES} || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'MAILADDRESSES'} || ''
MC/DC0%0/1
$ENV{'MAILADDRESSES'} || ''
$ENV{'MAILADDRESSES'}
Truth table0%0/2
A
A= $ENV{'MAILADDRESSES'}
| |||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my %nocc = (lc($id) => 1); | |||||||||||||||||||||||||||||||||||||
| 324 | $nocc{lc $_->address} = 1 | ||||||||||||||||||||||||||||||||||||||
| 325 | 0 | for Mail::Address->parse($reply->get('Bcc'), $mailaddresses); | |||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if($arg{ReplyAll}) # Who shall we copy this to | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 328 | 0 | { my %cc; | |||||||||||||||||||||||||||||||||||||
| 329 | 0 | foreach my $addr (Mail::Address->parse($self->get('To'), $self->get('Cc'))) | |||||||||||||||||||||||||||||||||||||
| 330 | 0 | { my $lc = lc $addr->address; | |||||||||||||||||||||||||||||||||||||
| 331 | $cc{$lc} = $addr->format | ||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | unless $nocc{$lc}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $cc = join ', ', values %cc; | |||||||||||||||||||||||||||||||||||||
| 335 | 0 | $reply->replace(Cc => $cc); | |||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | # References | ||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | my $refs = $self->get('References') || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get('References') || ''
MC/DC0%0/1
$self->get('References') || ''
$self->get('References')
Truth table0%0/2
A
A= $self->get('References')
| |||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $mid = $self->get('Message-Id'); | |||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $refs .= " " . $mid if defined $mid; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $reply->replace(References => $refs); | |||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||
| 345 | # In-Reply-To | ||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $date = $self->get('Date'); | |||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $inreply = ""; | |||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if(defined $mid) | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 350 | 0 | { $inreply = $mid; | |||||||||||||||||||||||||||||||||||||
| 351 | 0 | my @comment; | |||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | push @comment, "from $name" if defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | push @comment, "on $date" if defined $date; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 354 | 0 | local $" = ' '; | |||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $inreply .= " (@comment)" if @comment; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||
| 357 | elsif(defined $name) | ||||||||||||||||||||||||||||||||||||||
| 358 | 0 | { $inreply = $name . "'s message"; | |||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $inreply .= "of " . $date if defined $date; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $reply->replace('In-Reply-To' => $inreply); | |||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||
| 363 | # Quote the body | ||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $body = $reply->body; | |||||||||||||||||||||||||||||||||||||
| 365 | 0 | @$body = @{$self->body}; # copy body | |||||||||||||||||||||||||||||||||||||
| 366 | 0 | $reply->remove_sig; | |||||||||||||||||||||||||||||||||||||
| 367 | 0 | $reply->tidy_body; | |||||||||||||||||||||||||||||||||||||
| 368 | 0 | s/\A/$indent/ for @$body; | |||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||
| 370 | # Add references | ||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | unshift @{$body}, (defined $name ? $name . " " : "") . "<$id> writes:\n"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if(defined $arg{Keep} && ref $arg{Keep} eq 'ARRAY') # Include lines | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg{"Keep"} and ref $arg{"Keep"} eq "ARRAY"
MC/DC0%0/2
defined $arg{"Keep"} and ref $arg{"Keep"} eq "ARRAY"
defined $arg{"Keep"}
ref $arg{"Keep"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $arg{"Keep"}B= ref $arg{"Keep"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||
| 374 | 0 | { foreach my $keep (@{$arg{Keep}}) | |||||||||||||||||||||||||||||||||||||
| 375 | 0 | { my $ln = $self->get($keep); | |||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | $reply->replace($keep => $ln) if defined $ln; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if(defined $arg{Exclude} && ref $arg{Exclude} eq 'ARRAY') # Exclude lines | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg{"Exclude"} and ref $arg{"Exclude"} eq "ARRAY"
MC/DC0%0/2
defined $arg{"Exclude"} and ref $arg{"Exclude"} eq "ARRAY"
defined $arg{"Exclude"}
ref $arg{"Exclude"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $arg{"Exclude"}B= ref $arg{"Exclude"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||
| 381 | 0 | { $reply->delete(@{$arg{Exclude}}); | |||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $reply->head->cleanup; # remove empty header lines | |||||||||||||||||||||||||||||||||||||
| 385 | 0 | $reply; | |||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||
| 389 | sub smtpsend($@) | ||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | { my ($self, %opt) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
smtpsend: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | 0 | require Net::SMTP; | |||||||||||||||||||||||||||||||||||||
| 393 | 0 | require Net::Domain; | |||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $host = $opt{Host}; | |||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | my $envelope = $opt{MailFrom} || mailaddress(); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{'MailFrom'} || &mailaddress()
MC/DC0%0/2
$opt{'MailFrom'} || &mailaddress()
$opt{'MailFrom'}
&mailaddress()
Truth table0%0/3
A || B
A= $opt{'MailFrom'}B= &mailaddress()
| |||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $quit = 1; | |||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ($smtp, @hello); | |||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||
| 401 | push @hello, Hello => $opt{Hello} | ||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if defined $opt{Hello}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||
| 404 | push @hello, Port => $opt{Port} | ||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if exists $opt{Port}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||
| 407 | push @hello, Debug => $opt{Debug} | ||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if exists $opt{Debug}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if(!defined $host) | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 411 | 0 | { local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||||||||
| 412 | 0 | my @hosts = qw(mailhost localhost); | |||||||||||||||||||||||||||||||||||||
| 413 | unshift @hosts, split /\:/, $ENV{SMTPHOSTS} | ||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if defined $ENV{SMTPHOSTS}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||
| 416 | 0 | foreach $host (@hosts) | |||||||||||||||||||||||||||||||||||||
| 417 | 0 | { $smtp = eval { Net::SMTP->new($host, @hello) }; | |||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | last if defined $smtp; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||
| 421 | ▶ | elsif(UNIVERSAL::isa($host,'Net::SMTP') | |||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
UNIVERSAL::isa($host, "Net::SMTP") or UNIVERSAL::isa($host, "Net::SMTP::SSL")
MC/DC0%0/2
UNIVERSAL::isa($host, "Net::SMTP") or UNIVERSAL::isa($host, "Net::SMTP::SSL")
UNIVERSAL::isa($host, "Net::SMTP")
UNIVERSAL::isa($host, "Net::SMTP::SSL")
Truth table0%0/3
A or B
A= UNIVERSAL::isa($host, "Net::SMTP")B= UNIVERSAL::isa($host, "Net::SMTP::SSL")
| |||||||||||||||||||||||||||||||||||||||
| 422 | || UNIVERSAL::isa($host,'Net::SMTP::SSL')) | ||||||||||||||||||||||||||||||||||||||
| 423 | 0 | { $smtp = $host; | |||||||||||||||||||||||||||||||||||||
| 424 | 0 | $quit = 0; | |||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||
| 426 | else | ||||||||||||||||||||||||||||||||||||||
| 427 | 0 | { local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||||||||
| 428 | 0 | $smtp = eval { Net::SMTP->new($host, @hello) }; | |||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | defined $smtp or return (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $head = $self->cleaned_header_dup; | |||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||
| 435 | # Who is it to | ||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | my @rcpt = map { ref $_ ? @$_ : $_ } grep { defined } @opt{'To','Cc','Bcc'}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | @rcpt = map { $head->get($_) } qw(To Cc Bcc) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 439 | unless @rcpt; | ||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my @addr = map {$_->address} Mail::Address->parse(@rcpt); | |||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | @addr or return (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $head->delete('Bcc'); | |||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||
| 446 | # Send it | ||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||
| 448 | my $ok = $smtp->mail($envelope) | ||||||||||||||||||||||||||||||||||||||
| 449 | && $smtp->to(@addr) | ||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | && $smtp->data(join("", @{$head->header}, "\n", @{$self->body})); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$smtp->mail($envelope) && $smtp->to(@addr) && $smtp->data(join('', @{$head->header;}, "\n", @{$self->body;}))
$smtp->mail($envelope) and $smtp->to(@addr)
MC/DC0%0/3
$smtp->mail($envelope) && $smtp->to(@addr) && $smtp->data(join('', @{$head->header;}, "\n", @{$self->body;}))
$smtp->mail($envelope)
$smtp->to(@addr)
$smtp->data(join('', @{$head->header;}, "\n", @{$self->body;}))
Truth table0%0/4
A and B && C
A= $smtp->mail($envelope)B= $smtp->to(@addr)C= $smtp->data(join('', @{$head->header;}, "\n", @{$self->body;}))
| |||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | $quit && $smtp->quit; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | $ok ? @addr : (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||
| 457 | sub send($@) | ||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | { my ($self, $type, @args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||
| 460 | 0 | require Mail::Mailer; | |||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $head = $self->cleaned_header_dup; | |||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $mailer = Mail::Mailer->new($type, @args); | |||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $mailer->open($head->header_hashref); | |||||||||||||||||||||||||||||||||||||
| 466 | 0 | $self->print_body($mailer); | |||||||||||||||||||||||||||||||||||||
| 467 | 0 | $mailer->close; | |||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||
| 471 | sub nntppost | ||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | { my ($self, %opt) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
nntppost: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||
| 474 | 0 | require Net::NNTP; | |||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | my $groups = $self->get('Newsgroups') || ""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get('Newsgroups') || ''
MC/DC0%0/1
$self->get('Newsgroups') || ''
$self->get('Newsgroups')
Truth table0%0/2
A
A= $self->get('Newsgroups')
| |||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my @groups = split /[\s,]+/, $groups; | |||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | @groups or return (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $head = $self->cleaned_header_dup; | |||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||
| 482 | # Remove these incase the NNTP host decides to mail as well as me | ||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $head->delete(qw(To Cc Bcc)); | |||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $news; | |||||||||||||||||||||||||||||||||||||
| 486 | 0 | my $quit = 1; | |||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $host = $opt{Host}; | |||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if(ref($host) && UNIVERSAL::isa($host,'Net::NNTP')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $host and UNIVERSAL::isa($host, "Net::NNTP")
MC/DC0%0/2
ref $host and UNIVERSAL::isa($host, "Net::NNTP")
ref $host
UNIVERSAL::isa($host, "Net::NNTP")
Truth table0%0/3
A and B
A= ref $hostB= UNIVERSAL::isa($host, "Net::NNTP")
| |||||||||||||||||||||||||||||||||||||||
| 490 | 0 | { $news = $host; | |||||||||||||||||||||||||||||||||||||
| 491 | 0 | $quit = 0; | |||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||
| 493 | else | ||||||||||||||||||||||||||||||||||||||
| 494 | 0 | { my @opt = $opt{Host}; | |||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||
| 496 | push @opt, Port => $opt{Port} | ||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if exists $opt{Port}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||
| 499 | push @opt, Debug => $opt{Debug} | ||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if exists $opt{Debug}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | $news = Net::NNTP->new(@opt) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 503 | or return (); | ||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $news->post(@{$head->header}, "\n", @{$self->body}); | |||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $rc = $news->code; | |||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | $news->quit if $quit; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | $rc == 240 ? @groups : (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||
| 515 | sub escape_from | ||||||||||||||||||||||||||||||||||||||
| 516 | 2 | ▶ | { my $body = shift->body; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 517 | 2 | scalar grep { s/\A(>*From) />$1 /o } @$body; | |||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||
| 522 | sub unescape_from | ||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | { my $body = shift->body; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
unescape_from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 524 | 0 | scalar grep { s/\A>(>*From) /$1 /o } @$body; | |||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||
| 527 | # Don't tell people it exists | ||||||||||||||||||||||||||||||||||||||
| 528 | sub cleaned_header_dup() | ||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | { my $head = shift->head->dup; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
cleaned_header_dup: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $head->delete('From '); # Just in case :-) | |||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||
| 533 | # An original message should not have any Received lines | ||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $head->delete('Received'); | |||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | $head->replace('X-Mailer', "Perl5 Mail::Internet v".$Mail::Internet::VERSION) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 537 | unless $head->count('X-Mailer'); | ||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my $name = eval {local $SIG{__DIE__}; (getpwuid($>))[6]} || $ENV{NAME} ||""; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
eval {
do {
local $SIG{'__DIE__'};
(getpwuid $>)[6]
}
} || $ENV{'NAME'} || ''
eval {
do {
local $SIG{"__DIE__"};
(getpwuid $>)[6]
}
} or $ENV{"NAME"}
MC/DC0%0/2
eval {
do {
local $SIG{'__DIE__'};
(getpwuid $>)[6]
}
} || $ENV{'NAME'} || ''
eval {
do {
local $SIG{"__DIE__"};
(getpwuid $>)[6]
}
}
$ENV{"NAME"}
Truth table0%0/3
A or B
A= eval {
do {
local $SIG{"__DIE__"};
(getpwuid $>)[6]
}
}B= $ENV{"NAME"}
| |||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | while($name =~ s/\([^\(\)]*\)//) { 1; } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if($name =~ /[^\w\s]/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 544 | 0 | { $name =~ s/"/\"/g; | |||||||||||||||||||||||||||||||||||||
| 545 | 0 | $name = '"' . $name . '"'; | |||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $from = sprintf "%s <%s>", $name, mailaddress(); | |||||||||||||||||||||||||||||||||||||
| 549 | 0 | $from =~ s/\s{2,}/ /g; | |||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||
| 551 | 0 | foreach my $tag (qw(From Sender)) | |||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | { $head->get($tag) or $head->add($tag, $from); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $head; | |||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||
| 558 | 2 | 1; | |||||||||||||||||||||||||||||||||||||