| 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::Field; | ||||||||||||||||||||||||||||||||||||||||||||
| 10 | 53 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 11 | 53 | $VERSION = '3.013'; | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 53 | ▶ | use base 'Mail::Reporter'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 53 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 53 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 53 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 19 | 53 | ▶ | use Mail::Address; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 53 | ▶ | use Date::Format 'strftime'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 53 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | 53 | our %_structured; # not to be used directly: call isStructured! | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 53 | my $default_wrap_length = 78; | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | use overload | ||||||||||||||||||||||||||||||||||||||||||||
| 28 | 476 | ▶ | qq("") => sub { $_[0]->unfoldedBody } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | , '0+' => sub { $_[0]->toInt || 0 } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2515 | ▶ | , bool => sub {1} | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 157 | ▶ | , cmp => sub { $_[0]->unfoldedBody cmp "$_[1]" } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | ▶ | , '<=>' => sub { $_[2] ? $_[1] <=> $_[0]->toInt : $_[0]->toInt <=> $_[1] } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 53 | ▶ | , fallback => 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | sub new(@) | ||||||||||||||||||||||||||||||||||||||||||||
| 39 | 756 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 756 | ▶ | if($class eq __PACKAGE__) # bootstrap | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 614 | { require Mail::Message::Field::Fast; | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 614 | return Mail::Message::Field::Fast->new(@_); | |||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 44 | 142 | $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 176 | ▶ | sub length { length shift->folded } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
| 56 | 53 | ▶ | %_structured = map { (lc($_) => 1) } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 57 | qw/To Cc Bcc From Date Reply-To Sender | ||||||||||||||||||||||||||||||||||||||||||||
| 58 | Resent-Date Resent-From Resent-Sender Resent-To Return-Path | ||||||||||||||||||||||||||||||||||||||||||||
| 59 | List-Help List-Post List-Unsubscribe Mailing-List | ||||||||||||||||||||||||||||||||||||||||||||
| 60 | Received References Message-ID In-Reply-To | ||||||||||||||||||||||||||||||||||||||||||||
| 61 | Content-Type Content-Disposition Content-ID | ||||||||||||||||||||||||||||||||||||||||||||
| 62 | Delivered-To | ||||||||||||||||||||||||||||||||||||||||||||
| 63 | MIME-Version | ||||||||||||||||||||||||||||||||||||||||||||
| 64 | Precedence | ||||||||||||||||||||||||||||||||||||||||||||
| 65 | Status/; | ||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub isStructured(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 69 | 756 | ▶ | { my $name = ref $_[0] ? shift->name : $_[1]; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isStructured: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 756 | exists $_structured{lc $name}; | |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | sub print(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 75 | 21 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 21 | ▶ | 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()
| |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 21 | $fh->print(scalar $self->folded); | |||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 27 | ▶ | sub toString(;$) {shift->string(@_)} | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub string(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 83 | 93 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 93 | ▶ | return $self->folded unless @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | my $wrap = shift || $default_wrap_length; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $default_wrap_length
MC/DC0%0/2
shift() || $default_wrap_length
shift()
$default_wrap_length
Truth table33%1/3
A || B
A= shift()B= $default_wrap_length
| |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | my $name = $self->Name; | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | my @lines = $self->fold($name, $self->unfoldedBody, $wrap); | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | $lines[0] = $name . ':' . $lines[0]; | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | ▶ | wantarray ? @lines : join('', @lines); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | sub toDisclose() | ||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | { shift->name !~ m!^(?: (?:x-)?status | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toDisclose: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 96 | | (?:resent-)?bcc | ||||||||||||||||||||||||||||||||||||||||||||
| 97 | | Content-Length | ||||||||||||||||||||||||||||||||||||||||||||
| 98 | | x-spam- | ||||||||||||||||||||||||||||||||||||||||||||
| 99 | ) $!x; | ||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 139 | ▶ | sub nrLines() { my @l = shift->foldedBody; scalar @l } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nrLines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 53 | *size = \&length; | |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | # attempt to change the case of a tag to that required by RFC822. That | ||||||||||||||||||||||||||||||||||||||||||||
| 112 | # being all characters are lowercase except the first of each | ||||||||||||||||||||||||||||||||||||||||||||
| 113 | # word. Also if the word is an `acronym' then all characters are | ||||||||||||||||||||||||||||||||||||||||||||
| 114 | # uppercase. We, rather arbitrarily, decide that a word is an acronym | ||||||||||||||||||||||||||||||||||||||||||||
| 115 | # if it does not contain a vowel and isn't the well-known 'Cc' or | ||||||||||||||||||||||||||||||||||||||||||||
| 116 | # 'Bcc' headers. | ||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 53 | my %wf_lookup | |||||||||||||||||||||||||||||||||||||||||||
| 119 | = qw/mime MIME ldap LDAP soap SOAP swe SWE | ||||||||||||||||||||||||||||||||||||||||||||
| 120 | bcc Bcc cc Cc id ID/; | ||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | sub wellformedName(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 123 | 27 | ▶ | { my $thing = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wellformedName: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 27 | ▶ | my $name = @_ ? shift : $thing->name; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | join '-', | ||||||||||||||||||||||||||||||||||||||||||||
| 127 | 27 | ▶ | map { $wf_lookup{lc $_} || ( /[aeiouyAEIOUY]/ ? ucfirst lc : uc ) } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 128 | split /\-/, $name, -1; | ||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub folded { shift->notImplemented } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
folded: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | sub body() | ||||||||||||||||||||||||||||||||||||||||||||
| 138 | 724 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 724 | my $body = $self->unfoldedBody; | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 724 | ▶ | return $body unless $self->isStructured; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 510 | my ($first) = $body =~ m/^((?:"[^"]*"|'[^']*'|[^;])*)/; | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 510 | $first =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 510 | $first; | |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub foldedBody { shift->notImplemented } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foldedBody: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub unfoldedBody { shift->notImplemented } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unfoldedBody: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | sub stripCFWS($) | ||||||||||||||||||||||||||||||||||||||||||||
| 155 | 55 | ▶ | { my $thing = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stripCFWS: called CC=12 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | # get (folded) data | ||||||||||||||||||||||||||||||||||||||||||||
| 158 | 55 | ▶ | my $string = @_ ? shift : $thing->foldedBody; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | # remove comments | ||||||||||||||||||||||||||||||||||||||||||||
| 161 | 55 | my $r = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 55 | my $in_dquotes = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 55 | my $open_paren = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 55 | my @s = split m/([()"])/, $string; | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 55 | ▶ | while(@s) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 472 | { my $s = shift @s; | |||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 472 | ▶ | if(CORE::length($r)&& substr($r, -1) eq "\\") { $r .= $s } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition100%3/3
CORE::length $r and substr($r, -1) eq "\\"
MC/DC100%2/2
CORE::length $r and substr($r, -1) eq "\\"
CORE::length $r
substr($r, -1) eq "\\"
Truth table100%3/3
A and B
A= CORE::length $rB= substr($r, -1) eq "\\"
| |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 40 | elsif($s eq '"') { $in_dquotes = not $in_dquotes; $r .= $s } | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 80 | ▶ | elsif($s eq '(' && !$in_dquotes) { $open_paren++ } | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$s eq "(" and not $in_dquotes
MC/DC100%2/2
$s eq "(" and not $in_dquotes
$s eq "("
not $in_dquotes
Truth table100%3/3
A and not(B)
A= $s eq "("B= not $in_dquotes
| |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 80 | ▶ | elsif($s eq ')' && !$in_dquotes) { $open_paren-- } | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$s eq ")" and not $in_dquotes
MC/DC100%2/2
$s eq ")" and not $in_dquotes
$s eq ")"
not $in_dquotes
Truth table100%3/3
A and not(B)
A= $s eq ")"B= not $in_dquotes
| |||||||||||||||||||||||||||||||||||||||||||||
| 173 | elsif($open_paren) {} # in comment | ||||||||||||||||||||||||||||||||||||||||||||
| 174 | 156 | else { $r .= $s } | |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | # beautify and unfold at the same time | ||||||||||||||||||||||||||||||||||||||||||||
| 178 | 55 | for($r) | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 55 | { s/\s+/ /gs; | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 55 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 55 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 55 | $r; | |||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub comment(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 191 | 31 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comment: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 31 | ▶ | return undef unless $self->isStructured; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 27 | my $body = $self->unfoldedBody; | |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 27 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | { my $comment = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $body =~ s/\s*\;.*//; | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | $body .= "; $comment" if defined $comment && CORE::length($comment); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $comment and CORE::length $comment
MC/DC0%0/2
defined $comment and CORE::length $comment
defined $comment
CORE::length $comment
Truth table33%1/3
A and B
A= defined $commentB= CORE::length $comment
| |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | $self->unfoldedBody($body); | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | return $comment; | |||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 25 | ▶ | $body =~ s/.*?\;\s*// ? $body : ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | ▶ | sub content() { shift->unfoldedBody } # Compatibility | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | sub attribute($;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 211 | 412 | ▶ | { my ($self, $attr) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=9 SCAR=22.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 412 | my $body = $self->unfoldedBody; | |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | 412 | ▶ | unless(@_) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 215 | { # only get a value | ||||||||||||||||||||||||||||||||||||||||||||
| 216 | 287 | ▶ | if($body =~ m/\b$attr\s*\=\s* | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 217 | ( "( (?> [^\\"]+|\\. )* )" | ||||||||||||||||||||||||||||||||||||||||||||
| 218 | | ([^";\s]*) | ||||||||||||||||||||||||||||||||||||||||||||
| 219 | )/xi) | ||||||||||||||||||||||||||||||||||||||||||||
| 220 | 188 | { (my $val = $+) =~ s/\\(.)/$1/g; | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 188 | return $val; | |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 223 | 99 | return undef; | |||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | # set the value | ||||||||||||||||||||||||||||||||||||||||||||
| 227 | 125 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 125 | ▶ | unless(defined $value) # remove attribute | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | { for($body) | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | { s/\b$attr\s*=\s*"(?>[^\\"]|\\.)*"//i | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 231 | or s/\b$attr\s*=\s*[;\s]*//i; | ||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->unfoldedBody($body); | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 125 | (my $quoted = $value) =~ s/(["\\])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | 125 | for($body) | |||||||||||||||||||||||||||||||||||||||||||
| 240 | { s/\b$attr\s*=\s*"(?>[^\\"]|\\.){0,1000}"/$attr="$quoted"/i | ||||||||||||||||||||||||||||||||||||||||||||
| 241 | or s/\b$attr\s*=\s*[^;\s]*/$attr="$quoted"/i | ||||||||||||||||||||||||||||||||||||||||||||
| 242 | 125 | ▶ | or do { $_ .= qq(; $attr="$quoted") } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
s/\b$attr\s*=\s*"(?>[^\\"]|\\.){0,1000}"/$attr="$quoted"/i or s/\b$attr\s*=\s*[^;\s]*/$attr="$quoted"/i
MC/DC100%2/2
s/\b$attr\s*=\s*"(?>[^\\"]|\\.){0,1000}"/$attr="$quoted"/i or s/\b$attr\s*=\s*[^;\s]*/$attr="$quoted"/i
s/\b$attr\s*=\s*"(?>[^\\"]|\\.){0,1000}"/$attr="$quoted"/i
s/\b$attr\s*=\s*[^;\s]*/$attr="$quoted"/i
Truth table100%3/3
A or B
A= s/\b$attr\s*=\s*"(?>[^\\"]|\\.){0,1000}"/$attr="$quoted"/iB= s/\b$attr\s*=\s*[^;\s]*/$attr="$quoted"/i
| |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 125 | $self->unfoldedBody($body); | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 125 | $value; | |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | sub attributes() | ||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my $body = $self->unfoldedBody; | |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | my @attrs; | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | while($body =~ m/\b(\w+)\s*\=\s* | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 258 | ( "( (?: [^"]|\\" )* )" | ||||||||||||||||||||||||||||||||||||||||||||
| 259 | | '( (?: [^']|\\' )* )' | ||||||||||||||||||||||||||||||||||||||||||||
| 260 | | ([^;\s]*) | ||||||||||||||||||||||||||||||||||||||||||||
| 261 | ) | ||||||||||||||||||||||||||||||||||||||||||||
| 262 | /xig) | ||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | { push @attrs, $1 => $+; | |||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | @attrs; | |||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | sub toInt() | ||||||||||||||||||||||||||||||||||||||||||||
| 273 | 12 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toInt: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 12 | ▶ | return $1 if $self->body =~ m/^\s*(\d+)\s*$/; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $self->log(WARNING => "Field content is not numerical: ". $self->toString); | |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 53 | my @weekday = qw/Sun Mon Tue Wed Thu Fri Sat Sun/; | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 53 | my @month = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; | |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | sub toDate(@) | ||||||||||||||||||||||||||||||||||||||||||||
| 288 | 16 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toDate: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 16 | ▶ | my @time = @_== 0 ? localtime() : @_==1 ? localtime(shift) : @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 290 | 16 | my $format = "$weekday[$time[6]], %d $month[$time[4]] %Y %H:%M:%S %z"; | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 16 | my $time = strftime $format, @time; | |||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | # for C libs which do not (GNU compliantly) support %z | ||||||||||||||||||||||||||||||||||||||||||||
| 294 | 16 | $time =~ s/ (\%z|[A-Za-z ]+)$/_tz_offset($1)/e; | |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | 16 | $time; | |||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | sub _tz_offset($) | ||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | { my $zone = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tz_offset: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | require Time::Zone; | |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | my $diff = $zone eq '%z' ? Time::Zone::tz_local_offset() | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 304 | : Time::Zone::tz_offset($zone); | ||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $minutes = int((abs($diff)+0.01) / 60); # float rounding errors | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $hours = int(($minutes+0.01) / 60); | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $minutes -= $hours * 60; | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sprintf( ($diff < 0 ? " -%02d%02d" : " +%02d%02d"), $hours, $minutes); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 18 | ▶ | sub addresses() { Mail::Address->parse(shift->unfoldedBody) } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addresses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | sub study() | ||||||||||||||||||||||||||||||||||||||||||||
| 320 | 78 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
study: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 78 | require Mail::Message::Field::Full; | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 78 | Mail::Message::Field::Full->new(scalar $self->folded); | |||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | sub dateToTimestamp($) | ||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | { my $string = $_[0]->stripCFWS($_[1]); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dateToTimestamp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | # in RFC822, FWSes can appear within the time. | ||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | $string =~ s/(\d\d)\s*\:\s*(\d\d)\s*\:\s*(\d\d)/$1:$2:$3/; | |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | require Date::Parse; | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | Date::Parse::str2time($string, 'GMT'); | |||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | #=notice Empty field: $name | ||||||||||||||||||||||||||||||||||||||||||||
| 343 | #Empty fields are not allowed, however sometimes found in messages constructed | ||||||||||||||||||||||||||||||||||||||||||||
| 344 | #by broken applications. You probably want to ignore this message unless you | ||||||||||||||||||||||||||||||||||||||||||||
| 345 | #wrote this broken application yourself. | ||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | sub consume($;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 348 | 965 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consume: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 965 | ▶ | my ($name, $body) = defined $_[1] ? @_ : split(/\s*\:\s*/, (shift), 2); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 965 | ▶ | Mail::Reporter->log(WARNING => "Illegal character in field name $name") | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 352 | if $name =~ m/[^\041-\071\073-\176]/; | ||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | # | ||||||||||||||||||||||||||||||||||||||||||||
| 355 | # Compose the body. | ||||||||||||||||||||||||||||||||||||||||||||
| 356 | # | ||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | 965 | ▶ | if(ref $body) # Objects or array | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 359 | 28 | ▶ | { my $flat = $self->stringifyData($body) or return (); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 360 | 28 | $body = $self->fold($name, $flat); | |||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 362 | elsif($body !~ s/\n+$/\n/g) # Added by user... | ||||||||||||||||||||||||||||||||||||||||||||
| 363 | 858 | { $body = $self->fold($name, $body); | |||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 365 | else # Created by parser | ||||||||||||||||||||||||||||||||||||||||||||
| 366 | { # correct erroneous wrap-seperators (dos files under UNIX) | ||||||||||||||||||||||||||||||||||||||||||||
| 367 | 79 | $body =~ s/[\012\015]+/\n/g; | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 79 | $body =~ s/^[ \t]*/ /; # start with one blank, folding kept unchanged | |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 79 | ▶ | $self->log(NOTICE => "Empty field: $name") | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 371 | if $body eq " \n"; | ||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 965 | ($name, $body); | |||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | sub stringifyData($) | ||||||||||||||||||||||||||||||||||||||||||||
| 381 | 28 | ▶ | { my ($self, $arg) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringifyData: called CC=13 SCAR=25.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 382 | 28 | my @addr; | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 28 | ▶ | foreach my $obj (ref $arg eq 'ARRAY' ? @$arg : ($arg)) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 384 | 33 | ▶ | { next unless defined $obj; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 33 | ▶ | if(!ref $obj) { push @addr, $obj; next } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 32 | ▶ | if($obj->isa('Mail::Address')) { push @addr, $obj->format; next } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | 13 | ▶ | if($obj->isa('Mail::Identity') || $obj->isa('User::Identity')) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$obj->isa("Mail::Identity") or $obj->isa("User::Identity")
MC/DC100%2/2
$obj->isa("Mail::Identity") or $obj->isa("User::Identity")
$obj->isa("Mail::Identity")
$obj->isa("User::Identity")
Truth table100%3/3
A or B
A= $obj->isa("Mail::Identity")B= $obj->isa("User::Identity")
| |||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | { require Mail::Message::Field::Address; | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 7 | push @addr, Mail::Message::Field::Address->coerce($obj)->string; | |||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 393 | elsif($obj->isa('User::Identity::Collection::Emails')) | ||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | { my @roles = $obj->roles or next; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | require Mail::Message::Field::AddrGroup; | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | my $group = Mail::Message::Field::AddrGroup->coerce($obj); | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | push @addr, $group->string if $group; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 399 | elsif($obj->isa('Mail::Message::Field')) | ||||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | my $folded = join ' ', $obj->foldedBody; | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 5 | $folded =~ s/^ //; | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | $folded =~ s/\n\z//; | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 5 | push @addr, $folded; | |||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 406 | else | ||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | { push @addr, "$obj"; # any other object is stringified | |||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | 28 | ▶ | @addr ? join(', ',@addr) : undef; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | sub setWrapLength(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 418 | 370 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setWrapLength: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 370 | ▶ | $self->foldedBody(scalar $self->fold($self->Name, $self->unfoldedBody, @_)) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 421 | if @_; | ||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | 370 | $self; | |||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | sub defaultWrapLength(;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultWrapLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | @_ ? ($default_wrap_length = shift) : $default_wrap_length; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | sub fold($$;$) | ||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1103 | ▶ | { my $thing = shift; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fold: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1103 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 1103 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 1103 | ▶ | my $wrap = shift || $default_wrap_length; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift() || $default_wrap_length
MC/DC0%0/2
shift() || $default_wrap_length
shift()
$default_wrap_length
Truth table66%2/3
A || B
A= shift()B= $default_wrap_length
| |||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1103 | ▶ | defined $line or $line = ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1103 | $line =~ s/\n(\s)/$1/gms; # Remove accidental folding | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 1103 | ▶ | return " \n" unless CORE::length($line); # empty field | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1100 | my @folded; | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 1100 | while(1) | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 1155 | ▶ | { my $max = $wrap - (@folded ? 1 : CORE::length($name) + 2); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1155 | my $min = $max >> 2; | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 1155 | ▶ | last if CORE::length($line) < $max; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | 55 | ▶ | $line =~ s/^ ( .{$min,$max} # $max to 30 chars | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$line =~ s/^ ( .{$min,$max} # $max to 30 chars
[;,] # followed at a ; or ,
)[ \t] # and then a WSP
//x or $line =~ s/^ ( .{$min,$max} ) # $max to 30 chars
[ \t] # followed by a WSP
//x or $line =~ s/^ ( .{$max,}? ) # longer, but minimal chars
[ \t] # followed by a WSP
//x
$line =~ s/^ ( .{$min,$max} # $max to 30 chars
[;,] # followed at a ; or ,
)[ \t] # and then a WSP
//x or $line =~ s/^ ( .{$min,$max} ) # $max to 30 chars
[ \t] # followed by a WSP
//x
MC/DC100%3/3
$line =~ s/^ ( .{$min,$max} # $max to 30 chars
[;,] # followed at a ; or ,
)[ \t] # and then a WSP
//x or $line =~ s/^ ( .{$min,$max} ) # $max to 30 chars
[ \t] # followed by a WSP
//x or $line =~ s/^ ( .{$max,}? ) # longer, but minimal chars
[ \t] # followed by a WSP
//x
$line =~ s/^ ( .{$min,$max} # $max to 30 chars
[;,] # followed at a ; or ,
)[ \t] # and then a WSP
//x
$line =~ s/^ ( .{$min,$max} ) # $max to 30 chars
[ \t] # followed by a WSP
//x
$line =~ s/^ ( .{$max,}? ) # longer, but minimal chars
[ \t] # followed by a WSP
//x
Truth table100%4/4
A or B or C
A= $line =~ s/^ ( .{$min,$max} # $max to 30 chars
[;,] # followed at a ; or ,
)[ \t] # and then a WSP
//xB= $line =~ s/^ ( .{$min,$max} ) # $max to 30 chars
[ \t] # followed by a WSP
//xC= $line =~ s/^ ( .{$max,}? ) # longer, but minimal chars
[ \t] # followed by a WSP
//x
| |||||||||||||||||||||||||||||||||||||||||||||
| 454 | [;,] # followed at a ; or , | ||||||||||||||||||||||||||||||||||||||||||||
| 455 | )[ \t] # and then a WSP | ||||||||||||||||||||||||||||||||||||||||||||
| 456 | //x | ||||||||||||||||||||||||||||||||||||||||||||
| 457 | || $line =~ s/^ ( .{$min,$max} ) # $max to 30 chars | ||||||||||||||||||||||||||||||||||||||||||||
| 458 | [ \t] # followed by a WSP | ||||||||||||||||||||||||||||||||||||||||||||
| 459 | //x | ||||||||||||||||||||||||||||||||||||||||||||
| 460 | || $line =~ s/^ ( .{$max,}? ) # longer, but minimal chars | ||||||||||||||||||||||||||||||||||||||||||||
| 461 | [ \t] # followed by a WSP | ||||||||||||||||||||||||||||||||||||||||||||
| 462 | //x | ||||||||||||||||||||||||||||||||||||||||||||
| 463 | || $line =~ s/^ (.*) //x; # everything | ||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | 55 | push @folded, " $1\n"; | |||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1100 | ▶ | push @folded, " $line\n" if CORE::length($line); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1100 | ▶ | wantarray ? @folded : join('', @folded); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||
| 473 | sub unfold($) | ||||||||||||||||||||||||||||||||||||||||||||
| 474 | 1867 | ▶ | { my $string = $_[1]; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unfold: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 475 | 1867 | for($string) | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 1867 | { s/\r?\n(\s)/$1/gs; # remove FWS | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 1867 | s/\r?\n/ /gs; | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 1867 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 1867 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1867 | $string; | |||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||
| 484 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||
| 487 | 53 | 1; | |||||||||||||||||||||||||||||||||||||||||||