| 1 | # Copyrights 2001-2023 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 distribution Mail-Message. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Message::Head::Complete; | ||||||||||||||||||||||||||||||||||||||
| 10 | 38 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 38 | $VERSION = '3.013'; | |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 38 | ▶ | use base 'Mail::Message::Head'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 16 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | 38 | ▶ | use Mail::Box::Parser; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 38 | ▶ | use Mail::Message::Head::Partial; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | 38 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 22 | 38 | ▶ | use List::Util qw/sum/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 23 | 38 | ▶ | use Sys::Hostname qw/hostname/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | sub clone(;@) | ||||||||||||||||||||||||||||||||||||||
| 27 | 56 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 28 | 56 | my $copy = ref($self)->new($self->logSettings); | |||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 56 | $copy->addNoRealize($_->clone) for $self->grepNames(@_); | |||||||||||||||||||||||||||||||||||||
| 31 | 56 | $copy->modified(1); | |||||||||||||||||||||||||||||||||||||
| 32 | 56 | $copy; | |||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | sub build(@) | ||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
build: called CC=7 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 38 | 4 | my $self = $class->new; | |||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | while(@_) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 40 | 25 | { my $name = shift; | |||||||||||||||||||||||||||||||||||||
| 41 | 25 | ▶ | defined $name or next; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | 25 | ▶ | if($name->isa('Mail::Message::Field')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 44 | 0 | { $self->add($name); | |||||||||||||||||||||||||||||||||||||
| 45 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 25 | my $content = shift; | |||||||||||||||||||||||||||||||||||||
| 49 | 25 | ▶ | defined $content or next; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 25 | ▶ | if(ref $content && $content->isa('Mail::Message::Field')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $content and $content->isa("Mail::Message::Field")
MC/DC0%0/2
ref $content and $content->isa("Mail::Message::Field")
ref $content
$content->isa("Mail::Message::Field")
Truth table33%1/3
A and B
A= ref $contentB= $content->isa("Mail::Message::Field")
| |||||||||||||||||||||||||||||||||||||||
| 52 | 0 | { $self->log(WARNING => "Field objects have an implied name ($name)"); | |||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->add($content); | |||||||||||||||||||||||||||||||||||||
| 54 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 25 | $self->add($name, $content); | |||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | 4 | $self; | |||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | sub isDelayed() {0} | ||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | 49 | ▶ | sub nrLines() { sum 1, map $_->nrLines, shift->orderedFields } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
nrLines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 70 | 62 | ▶ | sub size() { sum 1, map $_->size, shift->orderedFields } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | sub wrap($) | ||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | { my ($self, $length) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $_->setWrapLength($length) for $self->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | sub add(@) | ||||||||||||||||||||||||||||||||||||||
| 82 | 181 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | # Create object for this field. | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | my $field | ||||||||||||||||||||||||||||||||||||||
| 87 | = @_==1 && ref $_[0] ? shift # A fully qualified field is added. | ||||||||||||||||||||||||||||||||||||||
| 88 | 181 | ▶ | : ($self->{MMH_field_type} || 'Mail::Message::Field::Fast')->new(@_); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
@_ == 1 and ref $_[0]
$self->{'MMH_field_type'} || 'Mail::Message::Field::Fast'
MC/DC0%0/2
@_ == 1 and ref $_[0]
@_ == 1
ref $_[0]
MC/DC0%0/1
$self->{'MMH_field_type'} || 'Mail::Message::Field::Fast'
$self->{'MMH_field_type'}
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0]
Truth table50%1/2
A
A= $self->{'MMH_field_type'}
| |||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||
| 90 | 181 | ▶ | return if !defined $field; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||
| 92 | 181 | $field->setWrapLength; | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | # Put it in place. | ||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | 181 | my $known = $self->{MMH_fields}; | |||||||||||||||||||||||||||||||||||||
| 97 | 181 | my $name = $field->name; # is already lower-cased | |||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | 181 | $self->addOrderedFields($field); | |||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | 181 | ▶ | if(defined $known->{$name}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | { if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 103 | 2 | else { $known->{$name} = [ $known->{$name}, $field ] } | |||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||
| 105 | else | ||||||||||||||||||||||||||||||||||||||
| 106 | 178 | { $known->{$name} = $field; | |||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | 181 | $self->{MMH_modified}++; | |||||||||||||||||||||||||||||||||||||
| 110 | 181 | $field; | |||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | sub count($) | ||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { my $known = shift->{MMH_fields}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
count: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $value = $known->{lc shift}; | |||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | ! defined $value ? 0 | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 119 | : ref $value ? @$value | ||||||||||||||||||||||||||||||||||||||
| 120 | : 1; | ||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | 19 | ▶ | sub names() {shift->knownNames} | ||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | sub grepNames(@) | ||||||||||||||||||||||||||||||||||||||
| 128 | 62 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
grepNames: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 129 | 62 | my @take; | |||||||||||||||||||||||||||||||||||||
| 130 | 62 | ▶ | push @take, (ref $_ eq 'ARRAY' ? @$_ : $_) foreach @_; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | 62 | ▶ | return $self->orderedFields unless @take; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | 6 | my $take; | |||||||||||||||||||||||||||||||||||||
| 135 | 6 | ▶ | if(@take==1 && ref $take[0] eq 'Regexp') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@take == 1 and ref $take[0] eq "Regexp"
MC/DC0%0/2
@take == 1 and ref $take[0] eq "Regexp"
@take == 1
ref $take[0] eq "Regexp"
Truth table33%1/3
A and B
A= @take == 1B= ref $take[0] eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||
| 136 | 6 | { $take = $take[0]; # one regexp prepared already | |||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | else | ||||||||||||||||||||||||||||||||||||||
| 139 | { # I love this trick: | ||||||||||||||||||||||||||||||||||||||
| 140 | 0 | local $" = ')|(?:'; | |||||||||||||||||||||||||||||||||||||
| 141 | 0 | $take = qr/^(?:(?:@take))/i; | |||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||
| 144 | 6 | grep {$_->name =~ $take} $self->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | 38 | my @skip_none = qw/content-transfer-encoding content-disposition | |||||||||||||||||||||||||||||||||||||
| 149 | content-description content-id/; | ||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | 38 | my %skip_none = map { ($_ => 1) } @skip_none; | |||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||
| 153 | sub set(@) | ||||||||||||||||||||||||||||||||||||||
| 154 | 494 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 155 | 494 | ▶ | my $type = $self->{MMH_field_type} || 'Mail::Message::Field::Fast'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'MMH_field_type'} || 'Mail::Message::Field::Fast'
MC/DC0%0/1
$self->{'MMH_field_type'} || 'Mail::Message::Field::Fast'
$self->{'MMH_field_type'}
Truth table50%1/2
A
A= $self->{'MMH_field_type'}
| |||||||||||||||||||||||||||||||||||||||
| 156 | 494 | $self->{MMH_modified}++; | |||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | # Create object for this field. | ||||||||||||||||||||||||||||||||||||||
| 159 | 494 | ▶ | my $field = @_==1 && ref $_[0] ? shift->clone : $type->new(@_); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0]
MC/DC50%1/2
@_ == 1 and ref $_[0]
@_ == 1
ref $_[0]
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||
| 161 | 494 | my $name = $field->name; # is already lower-cased | |||||||||||||||||||||||||||||||||||||
| 162 | 494 | my $known = $self->{MMH_fields}; | |||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | # Internally, non-existing content-info are in the body stored as 'none' | ||||||||||||||||||||||||||||||||||||||
| 165 | # The header will not contain these lines. | ||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | 494 | ▶ | if($skip_none{$name} && $field->body eq 'none') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$skip_none{$name} and $field->body eq "none"
MC/DC100%2/2
$skip_none{$name} and $field->body eq "none"
$skip_none{$name}
$field->body eq "none"
Truth table100%3/3
A and B
A= $skip_none{$name}B= $field->body eq "none"
| |||||||||||||||||||||||||||||||||||||||
| 168 | 314 | { delete $known->{$name}; | |||||||||||||||||||||||||||||||||||||
| 169 | 314 | return $field; | |||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | 180 | $field->setWrapLength; | |||||||||||||||||||||||||||||||||||||
| 173 | 180 | $known->{$name} = $field; | |||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | 180 | $self->addOrderedFields($field); | |||||||||||||||||||||||||||||||||||||
| 176 | 180 | $field; | |||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | sub reset($@) | ||||||||||||||||||||||||||||||||||||||
| 181 | 12 | ▶ | { my ($self, $name) = (shift, lc shift); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||
| 183 | 12 | my $known = $self->{MMH_fields}; | |||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||
| 185 | 12 | ▶ | if(@_==0) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 186 | 11 | ▶ | { $self->{MMH_modified}++ if delete $known->{$name}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 187 | 11 | return (); | |||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||
| 190 | 1 | $self->{MMH_modified}++; | |||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | # Cloning required, otherwise double registrations will not be | ||||||||||||||||||||||||||||||||||||||
| 193 | # removed from the ordered list: that's controled by 'weaken' | ||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||
| 195 | 1 | my @fields = map $_->clone, @_; | |||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | if(@_==1) { $known->{$name} = $fields[0] } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 198 | 1 | else { $known->{$name} = [@fields] } | |||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $self->addOrderedFields(@fields); | |||||||||||||||||||||||||||||||||||||
| 201 | 1 | $self; | |||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | 10 | ▶ | sub delete($) { $_[0]->reset($_[1]) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | sub removeField($) | ||||||||||||||||||||||||||||||||||||||
| 209 | 8 | ▶ | { my ($self, $field) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeField: called CC=6 SCAR=19.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 210 | 8 | my $name = $field->name; | |||||||||||||||||||||||||||||||||||||
| 211 | 8 | my $known = $self->{MMH_fields}; | |||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||
| 213 | 8 | ▶ | if(!defined $known->{$name}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 214 | { ; } # complain | ||||||||||||||||||||||||||||||||||||||
| 215 | elsif(ref $known->{$name} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | { for(my $i=0; $i < @{$known->{$name}}; $i++) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||
| 218 | 2 | return splice @{$known->{$name}}, $i, 1 | |||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | if $known->{$name}[$i] eq $field; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||
| 222 | elsif($known->{$name} eq $field) | ||||||||||||||||||||||||||||||||||||||
| 223 | 6 | { return delete $known->{$name}; | |||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->log(WARNING => "Cannot remove field $name from header: not found."); | |||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||
| 232 | sub removeFields(@) | ||||||||||||||||||||||||||||||||||||||
| 233 | 49 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeFields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 234 | 49 | (bless $self, 'Mail::Message::Head::Partial')->removeFields(@_); | |||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | sub removeFieldsExcept(@) | ||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeFieldsExcept: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 240 | 0 | (bless $self, 'Mail::Message::Head::Partial')->removeFieldsExcept(@_); | |||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | 90 | ▶ | sub removeContentInfo() { shift->removeFields(qr/^Content-/, 'Lines') } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeContentInfo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||
| 247 | sub removeResentGroups(@) | ||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeResentGroups: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 249 | 0 | (bless $self, 'Mail::Message::Head::Partial')->removeResentGroups(@_); | |||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | sub removeListGroup(@) | ||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeListGroup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 255 | 0 | (bless $self, 'Mail::Message::Head::Partial')->removeListGroup(@_); | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | sub removeSpamGroups(@) | ||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
removeSpamGroups: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 261 | 0 | (bless $self, 'Mail::Message::Head::Partial')->removeSpamGroups(@_); | |||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||
| 265 | sub spamDetected() | ||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
spamDetected: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my @sgs = $self->spamGroups or return undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 268 | 0 | grep { $_->spamDetected } @sgs; | |||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||
| 272 | sub print(;$) | ||||||||||||||||||||||||||||||||||||||
| 273 | 35 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 274 | 35 | ▶ | my $fh = shift || select; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||
| 276 | $_->print($fh) | ||||||||||||||||||||||||||||||||||||||
| 277 | 35 | foreach $self->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||
| 279 | 35 | ▶ | if(ref $fh eq 'GLOB') { print $fh "\n" } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 280 | 35 | else { $fh->print("\n") } | |||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||
| 282 | 35 | $self; | |||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||
| 286 | sub printUndisclosed($) | ||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
printUndisclosed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||
| 289 | $_->print($fh) | ||||||||||||||||||||||||||||||||||||||
| 290 | 0 | foreach grep {$_->toDisclose} $self->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if(ref $fh eq 'GLOB') { print $fh "\n" } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 293 | 0 | else { $fh->print("\n") } | |||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self; | |||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||
| 299 | sub printSelected($@) | ||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | { my ($self, $fh) = (shift, shift); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
printSelected: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||
| 302 | 0 | foreach my $field ($self->orderedFields) | |||||||||||||||||||||||||||||||||||||
| 303 | 0 | { my $Name = $field->Name; | |||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $name = $field->name; | |||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||
| 307 | 0 | foreach my $pattern (@_) | |||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | { $found = ref $pattern?($Name =~ $pattern):($name eq lc $pattern); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | last if $found; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if(!$found) { ; } | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 313 | 0 | elsif(ref $fh eq 'GLOB') { print $fh "\n" } | |||||||||||||||||||||||||||||||||||||
| 314 | 0 | else { $fh->print("\n") } | |||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self; | |||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | sub toString() {shift->string} | ||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 322 | sub string() | ||||||||||||||||||||||||||||||||||||||
| 323 | 6 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||
| 325 | 6 | my @lines = map {$_->string} $self->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 326 | 6 | push @lines, "\n"; | |||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||
| 328 | 6 | ▶ | wantarray ? @lines : join('', @lines); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||
| 332 | sub resentGroups() | ||||||||||||||||||||||||||||||||||||||
| 333 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
resentGroups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 334 | 3 | require Mail::Message::Head::ResentGroup; | |||||||||||||||||||||||||||||||||||||
| 335 | 3 | Mail::Message::Head::ResentGroup->from($self); | |||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||
| 339 | sub addResentGroup(@) | ||||||||||||||||||||||||||||||||||||||
| 340 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
addResentGroup: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||
| 342 | 3 | require Mail::Message::Head::ResentGroup; | |||||||||||||||||||||||||||||||||||||
| 343 | 3 | ▶ | my $rg = @_==1 ? (shift) : Mail::Message::Head::ResentGroup->new(@_); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||
| 345 | 3 | my @fields = $rg->orderedFields; | |||||||||||||||||||||||||||||||||||||
| 346 | 3 | my $order = $self->{MMH_order}; | |||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||
| 348 | # Look for the first line which relates to resent groups | ||||||||||||||||||||||||||||||||||||||
| 349 | 3 | my $i; | |||||||||||||||||||||||||||||||||||||
| 350 | 3 | ▶ | for($i=0; $i < @$order; $i++) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 351 | 13 | ▶ | { next unless defined $order->[$i]; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 352 | 13 | ▶ | last if $rg->isResentGroupFieldName($order->[$i]->name); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||
| 355 | 3 | my $known = $self->{MMH_fields}; | |||||||||||||||||||||||||||||||||||||
| 356 | 3 | ▶ | while(@fields) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 357 | 15 | { my $f = pop @fields; | |||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||
| 359 | # Add to the order of fields | ||||||||||||||||||||||||||||||||||||||
| 360 | 15 | splice @$order, $i, 0, $f; | |||||||||||||||||||||||||||||||||||||
| 361 | 15 | weaken( $order->[$i] ); | |||||||||||||||||||||||||||||||||||||
| 362 | 15 | my $name = $f->name; | |||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||
| 364 | # Adds *before* in the list for get(). | ||||||||||||||||||||||||||||||||||||||
| 365 | 15 | ▶ | if(!defined $known->{$name}) {$known->{$name} = $f} | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 366 | 0 | elsif(ref $known->{$name} eq 'ARRAY'){unshift @{$known->{$name}},$f} | |||||||||||||||||||||||||||||||||||||
| 367 | 2 | else {$known->{$name} = [$f, $known->{$name}]} | |||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||
| 370 | 3 | $rg->messageHead($self); | |||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||
| 372 | # Oh, the header has changed! | ||||||||||||||||||||||||||||||||||||||
| 373 | 3 | $self->modified(1); | |||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||
| 375 | 3 | $rg; | |||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||
| 379 | sub listGroup() | ||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
listGroup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 381 | 0 | eval "require 'Mail::Message::Head::ListGroup'"; | |||||||||||||||||||||||||||||||||||||
| 382 | 0 | Mail::Message::Head::ListGroup->from($self); | |||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||
| 386 | sub addListGroup($) | ||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | { my ($self, $lg) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
addListGroup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $lg->attach($self); | |||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | sub spamGroups(@) | ||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
spamGroups: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 394 | 0 | require Mail::Message::Head::SpamGroup; | |||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my @types = @_ ? (types => \@_) : (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my @sgs = Mail::Message::Head::SpamGroup->from($self, @types); | |||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | wantarray || @_ != 1 ? @sgs : $sgs[0]; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
wantarray or @_ != 1
MC/DC0%0/2
wantarray or @_ != 1
wantarray
@_ != 1
Truth table0%0/3
A or B
A= wantarrayB= @_ != 1
| |||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||
| 401 | sub addSpamGroup($) | ||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | { my ($self, $sg) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
addSpamGroup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $sg->attach($self); | |||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||
| 406 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | sub timestamp() {shift->guessTimestamp || time} | ||||||||||||||||||||||||||||||||||||
|
Subroutine
timestamp: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||
| 412 | sub recvstamp() | ||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
recvstamp: called CC=5 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | return $self->{MMH_recvstamp} if exists $self->{MMH_recvstamp}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||
| 417 | my $recvd = $self->get('received', 0) or | ||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | return $self->{MMH_recvstamp} = undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $stamp = Mail::Message::Field->dateToTimestamp($recvd->comment); | |||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $self->{MMH_recvstamp} = defined $stamp && $stamp > 0 ? $stamp : undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stamp and $stamp > 0
MC/DC0%0/2
defined $stamp and $stamp > 0
defined $stamp
$stamp > 0
Truth table0%0/3
A and B
A= defined $stampB= $stamp > 0
| |||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||
| 426 | sub guessTimestamp() | ||||||||||||||||||||||||||||||||||||||
| 427 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
guessTimestamp: called CC=8 SCAR=25.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 428 | 2 | ▶ | return $self->{MMH_timestamp} if exists $self->{MMH_timestamp}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||
| 430 | 1 | my $stamp; | |||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | if(my $date = $self->get('date')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 432 | 1 | { $stamp = Mail::Message::Field->dateToTimestamp($date); | |||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||
| 435 | 1 | ▶ | unless($stamp) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 436 | 0 | { foreach (reverse $self->get('received')) | |||||||||||||||||||||||||||||||||||||
| 437 | 0 | { $stamp = Mail::Message::Field->dateToTimestamp($_->comment); | |||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | last if $stamp; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||
| 442 | 1 | ▶ | $self->{MMH_timestamp} = defined $stamp && $stamp > 0 ? $stamp : undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $stamp and $stamp > 0
MC/DC0%0/2
defined $stamp and $stamp > 0
defined $stamp
$stamp > 0
Truth table33%1/3
A and B
A= defined $stampB= $stamp > 0
| |||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||
| 445 | sub guessBodySize() | ||||||||||||||||||||||||||||||||||||||
| 446 | 26 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
guessBodySize: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||
| 448 | 26 | my $cl = $self->get('Content-Length'); | |||||||||||||||||||||||||||||||||||||
| 449 | 26 | ▶ | return $1 if defined $cl && $cl =~ m/(\d+)/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $cl and $cl =~ /(\d+)/
MC/DC0%0/2
defined $cl and $cl =~ /(\d+)/
defined $cl
$cl =~ /(\d+)/
Truth table33%1/3
A and B
A= defined $clB= $cl =~ /(\d+)/
| |||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||
| 451 | 26 | my $lines = $self->get('Lines'); # 40 chars per lines | |||||||||||||||||||||||||||||||||||||
| 452 | 26 | ▶ | return $1 * 40 if defined $lines && $lines =~ m/(\d+)/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $lines and $lines =~ /(\d+)/
MC/DC0%0/2
defined $lines and $lines =~ /(\d+)/
defined $lines
$lines =~ /(\d+)/
Truth table33%1/3
A and B
A= defined $linesB= $lines =~ /(\d+)/
| |||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||
| 454 | 26 | undef; | |||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||
| 457 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||
| 460 | sub createFromLine() | ||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
createFromLine: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $sender = $self->message->sender; | |||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | my $stamp = $self->recvstamp || $self->timestamp || time; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->recvstamp || $self->timestamp || time
$self->recvstamp or $self->timestamp
MC/DC0%0/3
$self->recvstamp || $self->timestamp || time
$self->recvstamp
$self->timestamp
time
Truth table0%0/4
A or B || C
A= $self->recvstampB= $self->timestampC= time
| |||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | my $addr = defined $sender ? $sender->address : 'unknown'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 465 | 0 | "From $addr ".(gmtime $stamp)."\n" | |||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||
| 469 | 38 | my $msgid_creator; | |||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||
| 471 | sub createMessageId() | ||||||||||||||||||||||||||||||||||||||
| 472 | 120 | ▶ | { $msgid_creator ||= $_[0]->messageIdPrefix; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
createMessageId: called CC=2 SCAR=7.1
Pod
documented
Condition66%2/3
$msgid_creator ||= $_[0]->messageIdPrefix
MC/DC0%0/2
$msgid_creator ||= $_[0]->messageIdPrefix
$msgid_creator
$_[0]->messageIdPrefix
Truth table66%2/3
A ||= B
A= $msgid_creatorB= $_[0]->messageIdPrefix
| |||||||||||||||||||||||||||||||||||||||
| 473 | 120 | $msgid_creator->(@_); | |||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||
| 477 | sub messageIdPrefix(;$$) | ||||||||||||||||||||||||||||||||||||||
| 478 | 12 | ▶ | { my $thing = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
messageIdPrefix: called CC=11 SCAR=30.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | return $msgid_creator | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ or not defined $msgid_creator
MC/DC0%0/2
@_ or not defined $msgid_creator
@_
not defined $msgid_creator
Truth table33%1/3
A or not(B)
A= @_B= not defined $msgid_creator
| |||||||||||||||||||||||||||||||||||||||
| 480 | unless @_ || !defined $msgid_creator; | ||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||
| 482 | 12 | ▶ | return $msgid_creator = shift | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "CODE"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "CODE"
@_ == 1
ref $_[0] eq "CODE"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||||||||||||
| 483 | if @_==1 && ref $_[0] eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||
| 485 | 12 | ▶ | my $prefix = shift || "mailbox-$$"; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || "mailbox-${$}"
MC/DC0%0/1
shift() || "mailbox-${$}"
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||
| 487 | 12 | my $hostname = shift; | |||||||||||||||||||||||||||||||||||||
| 488 | 12 | ▶ | if(!defined $hostname) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 489 | 12 | { eval "require Net::Domain"; | |||||||||||||||||||||||||||||||||||||
| 490 | 12 | ▶ | $@ or $hostname = Net::Domain::hostfqdn(); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||
| 492 | 12 | ▶ | $hostname ||= hostname || 'localhost'; | ||||||||||||||||||||||||||||||||||||
|
Condition20%1/5
$hostname ||= hostname() || "localhost"
hostname() || 'localhost'
MC/DC0%0/2
$hostname ||= hostname() || "localhost"
$hostname
hostname()
Truth table33%1/3
A ||= B
A= $hostnameB= hostname()
| |||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||
| 494 | 12 | eval "require Time::HiRes"; | |||||||||||||||||||||||||||||||||||||
| 495 | 12 | ▶ | if(Time::HiRes->can('gettimeofday')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 496 | { | ||||||||||||||||||||||||||||||||||||||
| 497 | return $msgid_creator | ||||||||||||||||||||||||||||||||||||||
| 498 | 120 | ▶ | = sub { my ($sec, $micro) = Time::HiRes::gettimeofday(); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 499 | 120 | "$prefix-$sec-$micro\@$hostname"; | |||||||||||||||||||||||||||||||||||||
| 500 | 12 | }; | |||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $unique_id = time; | |||||||||||||||||||||||||||||||||||||
| 504 | $msgid_creator | ||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | = sub { $unique_id++; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 506 | 0 | "$prefix-$unique_id\@$hostname"; | |||||||||||||||||||||||||||||||||||||
| 507 | 0 | }; | |||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||
| 510 | 38 | 1; | |||||||||||||||||||||||||||||||||||||