| 1 | # Copyrights 2001-2022 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::Full; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 23 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 23 | $VERSION = '3.012'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 23 | ▶ | use base 'Mail::Message::Field'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 23 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 23 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 23 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 23 | ▶ | use MIME::QuotedPrint (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 23 | ▶ | use Storable 'dclone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 23 | ▶ | use Mail::Message::Field::Addresses; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 23 | ▶ | use Mail::Message::Field::AuthResults; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #use Mail::Message::Field::AuthRecChain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 23 | ▶ | use Mail::Message::Field::Date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 23 | ▶ | use Mail::Message::Field::DKIM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 23 | ▶ | use Mail::Message::Field::Structured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 23 | ▶ | use Mail::Message::Field::Unstructured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 23 | ▶ | use Mail::Message::Field::URIs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 23 | my $atext = q[a-zA-Z0-9!#\$%&'*+\-\/=?^_`{|}~]; # from RFC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 23 | my $atext_ill = q/\[\]/; # illegal, but still used (esp spam) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | ▶ | use overload '""' => sub { shift->decodedBody }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | my %implementation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $implementation{$_} = 'Addresses' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 23 | ▶ | for qw/from to sender cc bcc reply-to envelope-to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | resent-from resent-to resent-cc resent-bcc resent-reply-to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | resent-sender | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | x-beenthere errors-to mail-follow-up x-loop delivered-to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | original-sender x-original-sender/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | $implementation{$_} = 'URIs' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 23 | for qw/list-help list-post list-subscribe list-unsubscribe | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | list-archive list-owner/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $implementation{$_} = 'Structured' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 23 | for qw/content-disposition content-type content-id/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $implementation{$_} = 'Date' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 23 | for qw/date resent-date/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $implementation{$_} = 'AuthResults' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 23 | for qw/authentication-results/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $implementation{$_} = 'DKIM' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 23 | for qw/dkim-signature/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # $implementation{$_} = 'AuthRecChain' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # for qw/arc-authentication-results arc-message-signature arc-seal/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub new($;$$@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 118 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 118 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 118 | ▶ | my $body = @_ % 2 ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 118 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 118 | ▶ | $body = delete $args{body} if defined $args{body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 118 | ▶ | unless(defined $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 96 | { (my $n, $body) = split /\s*\:\s*/s, $name, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 96 | ▶ | $name = $n if defined $body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 118 | ▶ | return $class->SUPER::new(%args, name => $name, body => $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | if $class ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # Look for best class to suit this field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | my $myclass = 'Mail::Message::Field::' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 85 | ▶ | . ($implementation{lc $name} || 'Unstructured'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$implementation{lc $name} || 'Unstructured'
MC/DC100%1/1
$implementation{lc $name} || 'Unstructured'
$implementation{lc $name}
Truth table100%2/2
A
A= $implementation{lc $name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 85 | $myclass->SUPER::new(%args, name => $name, body => $body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 118 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 118 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 118 | $self->{MMFF_name} = $args->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 118 | my $body = $args->{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 118 | ▶ | if(!defined $body || !length $body || ref $body) { ; } # no body yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
not defined $body && length $body or ref $body
defined $body && length $body
MC/DC66%2/3
not defined $body && length $body or ref $body
defined $body
length $body
ref $body
Truth table75%3/4
not(A && B) or C
A= defined $bodyB= length $bodyC= ref $body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif(index($body, "\n") >= 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 86 | { $self->foldedBody($body) } # body is already folded | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 19 | else { $self->unfoldedBody($body) } # body must be folded | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 118 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub clone() { dclone(shift) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 162 | ▶ | sub name() { lc shift->{MMFF_name}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub Name() { shift->{MMFF_name}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sub folded() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 88 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
folded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 88 | ▶ | return $self->{MMFF_name}.':'.$self->foldedBody | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my @lines = $self->foldedBody; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $first = $self->{MMFF_name}. ':'. shift @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ($first, @lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | sub unfoldedBody($;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 219 | ▶ | { my ($self, $body) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unfoldedBody: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 219 | ▶ | if(defined $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 19 | { $self->foldedBody(scalar $self->fold($self->{MMFF_name}, $body)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 19 | return $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 200 | $body = $self->foldedBody; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 200 | $body =~ s/^ //; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # remove FWS, also required within quoted strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 200 | $body =~ s/\r?\n\s?/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 200 | $body =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 200 | $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | sub foldedBody($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 437 | ▶ | { my ($self, $body) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foldedBody: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 437 | ▶ | if(@_==2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 105 | { $self->parse($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 105 | $body =~ s/^\s*/ /m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 105 | $self->{MMFF_body} = $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | elsif(defined($body = $self->{MMFF_body})) { ; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { # Create a new folded body from the parts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | $self->{MMFF_body} = $body | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 55 | = $self->fold($self->{MMFF_name}, $self->produceBody); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 437 | ▶ | wantarray ? (split /^/, $body) : $body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | sub from($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | { my ($class, $field) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | defined $field ? $class->new($field->Name, $field->foldedBody, @_) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | sub decodedBody() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 81 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decodedBody: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 81 | $self->decode($self->unfoldedBody, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | sub createComment($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 38 | ▶ | { my ($thing, $comment) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createComment: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 38 | ▶ | $comment = $thing->encode($comment, @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | if @_; # encoding required... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Correct dangling parenthesis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 38 | local $_ = $comment; # work with a copy | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 38 | s#\\[()]#xx#g; # remove escaped parens | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 38 | s#[^()]#x#g; # remove other chars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 38 | ▶ | while( s#\(([^()]*)\)#x$1x# ) {;} # remove pairs of parens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 38 | ▶ | substr($comment, CORE::length($_), 0, '\\') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | while s#[()][^()]*$##; # add escape before remaining parens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 38 | $comment =~ s#\\+$##; # backslash at end confuses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 38 | "($comment)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub createPhrase($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 65 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createPhrase: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 65 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # I do not case whether it gets a but sloppy in the header string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # as long as it is functionally correct: no folding inside phrase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # quotes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 65 | ▶ | return $_ = $self->encode($_, @_, force => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | if length $_ > 50; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 63 | ▶ | $_ = $self->encode($_, @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | if @_; # encoding required... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 63 | ▶ | if( m/[^$atext]/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 48 | { s#\\#\\\\#g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 48 | s#"#\\"#g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 48 | $_ = qq["$_"]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 63 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub beautify() { shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beautify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 59 | ▶ | sub _mime_word($$) { "$_[0]$_[1]?=" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mime_word: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 15 | ▶ | sub _encode_b($) { MIME::Base64::encode_base64(shift, '') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_b: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub _encode_q($) # RFC2047 sections 4.2 and 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 668 | ▶ | { my $chunk = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_q: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 668 | $chunk =~ s#([^a-zA-Z0-9!*+/=_ -])#sprintf "=%02X", ord $1#ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 668 | $chunk =~ s#([_\?,"])#sprintf "=%02X", ord $1#ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 668 | $chunk =~ s/ /_/g; # special case for =? ?= use | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 668 | $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | sub encode($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 91 | ▶ | { my ($self, $utf8, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=20 SCAR=30.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 91 | my ($charset, $lang, $encoding); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 91 | ▶ | if($charset = $args{charset}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 28 | ▶ | { $self->log(WARNING => "Illegal character in charset '$charset'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | if $charset =~ m/[\x00-\ ()<>@,;:"\/[\]?.=\\]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 63 | else { $charset = 'us-ascii' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 91 | ▶ | if($lang = $args{language}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | ▶ | { $self->log(WARNING => "Illegal character in language '$lang'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | if $lang =~ m/[\x00-\ ()<>@,;:"\/[\]?.=\\]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 91 | ▶ | if($encoding = $args{encoding}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 11 | ▶ | { unless($encoding =~ m/^[bBqQ]$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | { $self->log(WARNING => "Illegal encoding '$encoding', used 'q'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $encoding = 'q'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 80 | else { $encoding = 'q' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 91 | my $name = $args{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 91 | ▶ | my $lname = defined $name ? length($name)+1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | return $utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | if lc($encoding) eq 'q' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | && length $utf8 < 70 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 91 | ▶ | && ($utf8 =~ m/\A[\p{IsASCII}]+\z/ms && !$args{force}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
lc $encoding eq "q" and length $utf8 < 70 and ($utf8 =~ /\A[\p{IsASCII}]+\z/ms and not $args{"force"})
lc $encoding eq "q" and length $utf8 < 70
$utf8 =~ /\A[\p{IsASCII}]+\z/ms and not $args{"force"}
MC/DC75%3/4
lc $encoding eq "q" and length $utf8 < 70 and ($utf8 =~ /\A[\p{IsASCII}]+\z/ms and not $args{"force"})
lc $encoding eq "q"
length $utf8 < 70
$utf8 =~ /\A[\p{IsASCII}]+\z/ms
not $args{"force"}
Truth table80%4/5
A and B and C and not(D)
A= lc $encoding eq "q"B= length $utf8 < 70C= $utf8 =~ /\A[\p{IsASCII}]+\z/msD= not $args{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 28 | ▶ | my $pre = '=?'. $charset. ($lang ? '*'.$lang : '') .'?'.$encoding.'?'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 28 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 28 | ▶ | if(lc($encoding) eq 'q') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 20 | { my $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 20 | my $llen = 73 - length($pre) - $lname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 20 | ▶ | while(length(my $chr = substr($utf8, 0, 1, ''))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 668 | { $chr = _encode_q Encode::encode($charset, $chr, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 668 | ▶ | if(bytes::length($chunk) + bytes::length($chr) > $llen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 24 | { push @result, _mime_word($pre, $chunk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 24 | $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 24 | $llen = 73 - length $pre; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 668 | $chunk .= $chr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 20 | ▶ | push @result, _mime_word($pre, $chunk) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if length($chunk); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | { my $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 8 | my $llen = int((73 - length($pre) - $lname) / 4) * 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 8 | ▶ | while(length(my $chr = substr($utf8, 0, 1, ''))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 310 | { my $chr = Encode::encode($charset, $chr, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 310 | ▶ | if(bytes::length($chunk) + bytes::length($chr) > $llen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 7 | { push @result, _mime_word($pre, _encode_b($chunk)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 7 | $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 7 | $llen = int((73 - length $pre) / 4) * 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 310 | $chunk .= $chr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | ▶ | push @result, _mime_word($pre, _encode_b($chunk)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | if length $chunk; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 28 | join ' ', @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | sub _decoder($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 41 | ▶ | { my ($charset, $encoding, $encoded) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decoder: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 41 | $charset =~ s/\*[^*]+$//; # language component not used | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 41 | ▶ | my $to_utf8 = Encode::find_encoding($charset || 'us-ascii'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$charset || 'us-ascii'
MC/DC100%1/1
$charset || 'us-ascii'
$charset
Truth table100%2/2
A
A= $charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 41 | ▶ | $to_utf8 or return $encoded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 41 | my $decoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 41 | ▶ | if($encoding !~ /\S/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | { $decoded = $encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | elsif(lc($encoding) eq 'q') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | { # Quoted-printable encoded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 32 | $encoded =~ s/_/ /g; # specific to mime-fields | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 32 | $decoded = MIME::QuotedPrint::decode_qp($encoded); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | elsif(lc($encoding) eq 'b') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | { # Base64 encoded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 8 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | $decoded = MIME::Base64::decode_base64($encoded); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | { # unknown encodings ignored | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return $encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 41 | $to_utf8->decode($decoded, Encode::FB_DEFAULT); # error-chars -> '?' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | sub decode($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 277 | ▶ | { my $thing = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 277 | my @encoded = split /(\=\?[^?\s]*\?[bqBQ]?\?[^?]*\?\=)/, shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 277 | ▶ | @encoded or return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 276 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 276 | ▶ | my $is_text = defined $args{is_text} ? $args{is_text} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 276 | my @decoded = shift @encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 276 | ▶ | while(@encoded) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 41 | { shift(@encoded) =~ /\=\?([^?\s]*)\?([^?\s]*)\?([^?]*)\?\=/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 41 | push @decoded, _decoder $1, $2, $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 41 | ▶ | @encoded or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # in text, blanks between encoding must be removed, but otherwise kept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 27 | ▶ | if($is_text && $encoded[0] !~ m/\S/) { shift @encoded } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_text and not $encoded[0] =~ /\S/
MC/DC50%1/2
$is_text and not $encoded[0] =~ /\S/
$is_text
not $encoded[0] =~ /\S/
Truth table66%2/3
A and not(B)
A= $is_textB= not $encoded[0] =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 10 | else { push @decoded, shift @encoded } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 276 | join '', @decoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 5 | ▶ | sub parse($) { shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | sub consumePhrase($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 183 | ▶ | { my ($thing, $string) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consumePhrase: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 183 | my $phrase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 183 | ▶ | if($string =~ s/^\s*\" ((?:[^"\r\n\\]*|\\.)*) (?:\"|\s*$)//x ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 82 | { ($phrase = $1) =~ s/\\\"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | elsif($string =~ s/^\s*((?:\=\?.*\?\=|[${atext}${atext_ill}\ \t.])+)//o ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 96 | { ($phrase = $1) =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 96 | ▶ | CORE::length($phrase) or undef $phrase; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 183 | ▶ | defined $phrase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | ? ($thing->decode($phrase), $string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | : (undef, $string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | sub consumeComment($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 608 | ▶ | { my ($thing, $string) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consumeComment: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 608 | ▶ | return (undef, $string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | unless $string =~ s/^\s*\(((?:[^)\\]+|\\.)*)\)//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 45 | my $comment = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 45 | while(1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 49 | { (my $count = $comment) =~ s/\\./xx/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 49 | ▶ | last if $count =~ tr/(// == $count =~ tr/)//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 5 | ▶ | return (undef, $_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | unless $string =~ s/^((?:[^)\\]+|\\.)*)\)//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | $comment .= ')'.$1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 44 | $comment =~ s/\\([()])/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 44 | ($comment, $string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | sub consumeDotAtom($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 72 | ▶ | { my ($self, $string) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consumeDotAtom: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 72 | my ($atom, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 72 | while(1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 147 | { (my $c, $string) = $self->consumeComment($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 147 | ▶ | if(defined $c) { $comment .= $c; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 142 | ▶ | last unless $string =~ s/^\s*([$atext]+(?:\.[$atext]+)*)//o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 70 | $atom .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 72 | ($atom, $string, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | sub produceBody() { $_[0]->{MMFF_body} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
produceBody: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||