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