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