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