Message/Body.pm

filter: Statementstmt 80.0% 181 / 226 Branchbran 69.2% 97 / 140 Conditioncond 61.0% 47 / 77 MC/DCmcdc 42.5% 20 / 47 Subroutinesub 65.4% 36 / 55 Podpod 94.1% 32 / 34 totaltotal 71.3% 413 / 579 SCAR 57.2
CC
103
Cov
73%
init
126.2
eol
27.1
write
20.0
CRAP 303.5
« Box/Parser/Perl.pm ↑ Summary Message/Head/SpamGroup.pm »
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::Body;
10 34 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 34 $VERSION = '3.013';
12  
13 34 ▶use base 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 34 ▶use Mail::Message::Field;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 34 ▶use Mail::Message::Body::Lines;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 34 ▶use Mail::Message::Body::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 34 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 34 ▶use Scalar::Util qw/weaken refaddr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 34 ▶use File::Basename qw/basename/;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 34 ▶use MIME::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 34 my $mime_types = MIME::Types->new;
28 34 my $mime_plain = $mime_types->type('text/plain');
29  
30  
31 use overload
32 573 ▶ bool => sub {1} # $body->print if $body
Subroutine __ANON__: called CC=1 SCAR=0.0
33 , '""' => 'string_unless_carp'
34 , '@{}' => 'lines'
35 14 ▶ , '==' => sub {ref $_[1] && refaddr $_[0] == refaddr $_[1]}
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
ref $_[1] and builtin::refaddr($_[0]) == builtin::refaddr($_[1]) 14 0 14
36 34 ▶ , '!=' => sub {ref $_[1] && refaddr $_[0] != refaddr $_[1]};
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
ref $_[1] and builtin::refaddr($_[0]) != builtin::refaddr($_[1]) 45 0 45
37  
38 #------------------------------------------
39  
40  
41 34 my $body_count = 0; # to be able to compare bodies for equivalence.
42  
43 sub new(@)
44 262 ▶{ my $class = shift;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
45  
46 262 ▶ return $class->SUPER::new(@_)
Branch: 1 branch
BranchTrueFalseTotal
unless $class eq __PACKAGE__ 243 19 262
47 unless $class eq __PACKAGE__;
48  
49 19 my %args = @_;
50  
51 exists $args{file}
52 19 ▶ ? Mail::Message::Body::File->new(@_)
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'file'} ? : 0 19 19
53 : Mail::Message::Body::Lines->new(@_);
54 }
55  
56 # All body implementations shall implement all of the following!!
57  
58 0 ▶sub _data_from_filename(@) {shift->notImplemented}
Subroutine _data_from_filename: not called CC=1 SCAR=6.9
59 0 ▶sub _data_from_filehandle(@) {shift->notImplemented}
Subroutine _data_from_filehandle: not called CC=1 SCAR=6.9
60 0 ▶sub _data_from_glob(@) {shift->notImplemented}
Subroutine _data_from_glob: not called CC=1 SCAR=6.9
61 0 ▶sub _data_from_lines(@) {shift->notImplemented}
Subroutine _data_from_lines: not called CC=1 SCAR=6.9
62  
63 sub init($)
64 243 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=45 SCAR=48.4
Pod undocumented
65  
66 243 $self->SUPER::init($args);
67  
68 243 ▶ $self->{MMB_modified} = $args->{modified} || 0;
Condition50%1/2
$args->{'modified'} || 0
l!l
0243
MC/DC0%0/1
$args->{'modified'} || 0
$args->{'modified'}
Truth table50%1/2
A
A= $args->{'modified'}
Aresult
11
00
69  
70 243 my $filename = $args->{filename};
71 243 my $mime = $args->{mime_type};
72  
73 243 ▶ if(defined(my $file = $args->{file}))
Branch: 3 branches
BranchTrueFalseTotal
if (defined(my $file = $args->{'file'})) { } 3 240 243
elsif (defined(my $data = $args->{'data'})) { } 154 86 240
elsif (not $self->isMultipart || $self->isNested) { } 32 54 86
74 {
75 3 ▶ if(!ref $file)
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $file) { } 0 3 3
elsif (ref $file eq 'GLOB') { } 0 3 3
elsif ($file->isa('IO::Handle')) { } 3 0 3
76 0 ▶ { $self->_data_from_filename($file) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_data_from_filename($file) or return 0 0 0
77 0 ▶ $filename ||= $file;
Condition0%0/3
$filename ||= $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$filename ||= $file
$filename $file
Truth table0%0/3
A ||= B
A= $filenameB= $file
ABresult
1X1
011
000
78 0 ▶ $mime ||= $mime_types->mimeTypeOf($filename)
Branch: 1 branch
BranchTrueFalseTotal
-T $file ? : 0 0 0
Condition0%0/6
$mime ||= $mime_types->mimeTypeOf($filename) || (-T $file ? "text/plain" : "application/octet-stream")
l!l&&r!l&&!r
000
$mime_types->mimeTypeOf($filename) || (-T $file ? 'text/plain' : 'application/octet-stream')
l!l&&r!l&&!r
000
MC/DC0%0/3
$mime ||= $mime_types->mimeTypeOf($filename) || (-T $file ? "text/plain" : "application/octet-stream")
$mime $mime_types->mimeTypeOf($filename) (-T $file ? 'text/plain' : 'application/octet-stream')
Truth table0%0/4
A ||= B || C
A= $mimeB= $mime_types->mimeTypeOf($filename)C= (-T $file ? 'text/plain' : 'application/octet-stream')
ABCresult
1XX1
01X1
0011
0000
79 || (-T $file ? 'text/plain' : 'application/octet-stream');
80 }
81 elsif(ref $file eq 'GLOB')
82 0 ▶ { $self->_data_from_glob($file) or return }
Branch: 1 branch
BranchTrueFalseTotal
$self->_data_from_glob($file) or return 0 0 0
83 elsif($file->isa('IO::Handle'))
84 3 ▶ { $self->_data_from_filehandle($file) or return }
Branch: 1 branch
BranchTrueFalseTotal
$self->_data_from_filehandle($file) or return 0 3 3
85 else
86 0 { croak "message body: illegal datatype `".ref($file)."' for file option" }
87 }
88 elsif(defined(my $data = $args->{data}))
89 {
90 154 ▶ if(!ref $data)
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $data) { } 88 66 154
elsif (ref $data eq 'ARRAY') { } 66 0 66
91 88 { my @lines = split /^/, $data;
92 88 $self->_data_from_lines(\@lines)
93 }
94 elsif(ref $data eq 'ARRAY')
95 66 ▶ { $self->_data_from_lines($data) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_data_from_lines($data) or return 0 66 66
96 }
97 else
98 0 { croak "message body: illegal datatype `".ref($data)."' for data option" }
99 }
100 ▶ elsif(! $self->isMultipart && ! $self->isNested)
Condition100%3/3
$self->isMultipart || $self->isNested
l!l&&r!l&&!r
411332
MC/DC100%2/2
$self->isMultipart || $self->isNested
$self->isMultipart $self->isNested
Truth table100%3/3
A || B
A= $self->isMultipartB= $self->isNested
ABresult
1X1
011
000
101 { # Neither 'file' nor 'data', so empty body.
102 32 ▶ $self->_data_from_lines( [] ) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_data_from_lines([]) or return 0 32 32
103 }
104  
105 # Set the content info
106  
107 my ($transfer, $disp, $descr, $cid) = @$args{
108 243 qw/transfer_encoding disposition description content_id/ };
109  
110 243 ▶ if(defined $filename)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $filename) 0 243 243
111 0 ▶ { $disp //= Mail::Message::Field->new
Branch: 1 branch
BranchTrueFalseTotal
-T $filename ? : 0 0 0
Condition0%0/3
$disp //= "Mail::Message::Field"->new("Content-Disposition", -T $filename ? "inline" : "attachment", "filename", basename($filename))
l!l&&r!l&&!r
000
MC/DC0%0/2
$disp //= "Mail::Message::Field"->new("Content-Disposition", -T $filename ? "inline" : "attachment", "filename", basename($filename))
$disp "Mail::Message::Field"->new("Content-Disposition", -T $filename ? "inline" : "attachment", "filename", basename($filename))
Truth table0%0/3
A //= B
A= $dispB= "Mail::Message::Field"->new("Content-Disposition", -T $filename ? "inline" : "attachment", "filename", basename($filename))
ABresult
1X1
011
000
112 ( 'Content-Disposition' => (-T $filename ? 'inline' : 'attachment')
113 , filename => basename($filename)
114 );
115 0 ▶ $mime //= $mime_types->mimeTypeOf($filename);
Condition0%0/3
$mime //= $mime_types->mimeTypeOf($filename)
l!l&&r!l&&!r
000
MC/DC0%0/2
$mime //= $mime_types->mimeTypeOf($filename)
$mime $mime_types->mimeTypeOf($filename)
Truth table0%0/3
A //= B
A= $mimeB= $mime_types->mimeTypeOf($filename)
ABresult
1X1
011
000
116 }
117  
118 243 ▶ if(ref $mime && $mime->isa('MIME::Type'))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $mime and $mime->isa("MIME::Type")) 0 243 243
Condition66%2/3
ref $mime and $mime->isa("MIME::Type")
!ll&&!rl&&r
177660
MC/DC0%0/2
ref $mime and $mime->isa("MIME::Type")
ref $mime $mime->isa("MIME::Type")
Truth table66%2/3
A and B
A= ref $mimeB= $mime->isa("MIME::Type")
ABresult
0X0
100
111
119 0 { $mime = $mime->type;
120 }
121  
122 243 ▶ if(defined(my $based = $args->{based_on}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $based = $args->{'based_on'})) { } 133 110 243
123 133 ▶ { $mime //= $based->type;
Condition66%2/3
$mime //= $based->type
l!l&&r!l&&!r
86470
MC/DC0%0/2
$mime //= $based->type
$mime $based->type
Truth table66%2/3
A //= B
A= $mimeB= $based->type
ABresult
1X1
011
000
124 133 ▶ $transfer //= $based->transferEncoding;
Condition66%2/3
$transfer //= $based->transferEncoding
l!l&&r!l&&!r
131200
MC/DC0%0/2
$transfer //= $based->transferEncoding
$transfer $based->transferEncoding
Truth table66%2/3
A //= B
A= $transferB= $based->transferEncoding
ABresult
1X1
011
000
125 133 ▶ $disp //= $based->disposition;
Condition33%1/3
$disp //= $based->disposition
l!l&&r!l&&!r
01330
MC/DC0%0/2
$disp //= $based->disposition
$disp $based->disposition
Truth table33%1/3
A //= B
A= $dispB= $based->disposition
ABresult
1X1
011
000
126 133 ▶ $descr //= $based->description;
Condition33%1/3
$descr //= $based->description
l!l&&r!l&&!r
01330
MC/DC0%0/2
$descr //= $based->description
$descr $based->description
Truth table33%1/3
A //= B
A= $descrB= $based->description
ABresult
1X1
011
000
127 133 ▶ $cid //= $based->contentId;
Condition33%1/3
$cid //= $based->contentId
l!l&&r!l&&!r
01330
MC/DC0%0/2
$cid //= $based->contentId
$cid $based->contentId
Truth table33%1/3
A //= B
A= $cidB= $based->contentId
ABresult
1X1
011
000
128  
129 $self->{MMB_checked}
130 133 ▶ = defined $args->{checked} ? $args->{checked} : $based->checked;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'checked'} ? : 46 87 133
131 }
132 else
133 110 { $transfer = $args->{transfer_encoding};
134 110 ▶ $self->{MMB_checked} = $args->{checked} || 0;
Condition100%2/2
$args->{'checked'} || 0
l!l
3107
MC/DC100%1/1
$args->{'checked'} || 0
$args->{'checked'}
Truth table100%2/2
A
A= $args->{'checked'}
Aresult
11
00
135 }
136  
137 243 ▶ $mime ||= 'text/plain';
Condition100%2/2
$mime ||= "text/plain"
l!l
19251
MC/DC100%1/1
$mime ||= "text/plain"
$mime
Truth table100%2/2
A
A= $mime
Aresult
11
00
138 243 $mime = $self->type($mime);
139  
140 243 ▶ my $default_charset = exists $args->{charset} ? $args->{charset} : 'PERL';
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{'charset'} ? : 29 214 243
141 243 ▶ $mime->attribute(charset => $default_charset)
Branch: 1 branch
BranchTrueFalseTotal
if $default_charset and $mime =~ m[^text/]i and not $mime->attribute("charset") 78 165 243
Condition100%6/6
$default_charset and $mime =~ m[^text/]i and not $mime->attribute("charset")
!ll&&!rl&&r
808578
$default_charset and $mime =~ m[^text/]i
!ll&&!rl&&r
2654163
MC/DC100%3/3
$default_charset and $mime =~ m[^text/]i and not $mime->attribute("charset")
$default_charset $mime =~ m[^text/]i not $mime->attribute("charset")
Truth table100%4/4
A and B and not(C)
A= $default_charsetB= $mime =~ m[^text/]iC= not $mime->attribute("charset")
ABCresult
0XX0
10X0
1100
1111
142 if $default_charset
143 && $mime =~ m!^text/!i
144 && !$mime->attribute('charset');
145  
146 243 ▶ $self->transferEncoding($transfer) if defined $transfer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $transfer 141 102 243
147 243 ▶ $self->disposition($disp) if defined $disp;
Branch: 1 branch
BranchTrueFalseTotal
if defined $disp 133 110 243
148 243 ▶ $self->description($descr) if defined $descr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $descr 133 110 243
149 243 ▶ $self->contentId($cid) if defined $cid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cid 133 110 243
150 243 $self->type($mime);
151  
152 243 ▶ $self->{MMB_eol} = $args->{eol} || 'NATIVE';
Condition100%2/2
$args->{'eol'} || 'NATIVE'
l!l
1242
MC/DC100%1/1
$args->{'eol'} || 'NATIVE'
$args->{'eol'}
Truth table100%2/2
A
A= $args->{'eol'}
Aresult
11
00
153  
154 # Set message where the body belongs to.
155  
156 $self->message($args->{message})
157 243 ▶ if defined $args->{message};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"message"} 26 217 243
158  
159 243 $self->{MMB_seqnr} = $body_count++;
160 243 $self;
161 }
162  
163  
164  
165 0 ▶sub clone() {shift->notImplemented}
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
166  
167 #------------------------------------------
168  
169  
170 sub decoded(@)
171 25 ▶{ my $self = shift;
Subroutine decoded: called CC=1 SCAR=0.0
Pod documented
172 25 $self->encode(charset => 'PERL', transfer_encoding => 'none', @_);
173 }
174  
175  
176 sub eol(;$)
177 2 ▶{ my $self = shift;
Subroutine eol: called CC=14 SCAR=33.0
Pod documented
178 2 ▶ return $self->{MMB_eol} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 1 2
179  
180 1 my $eol = shift;
181 1 ▶ if($eol eq 'NATIVE')
Branch: 1 branch
BranchTrueFalseTotal
if ($eol eq "NATIVE") 1 0 1
182 1 ▶ { $eol = $^O =~ m/^win/i ? 'CRLF'
Branch: 2 branches
BranchTrueFalseTotal
$^O =~ /^win/i ? : 0 1 1
$^O =~ /^mac/i ? : 0 1 1
183 : $^O =~ m/^mac/i ? 'CR'
184 : 'LF';
185 }
186  
187 1 ▶ return $self if $eol eq $self->{MMB_eol} && $self->checked;
Branch: 1 branch
BranchTrueFalseTotal
if $eol eq $self->{"MMB_eol"} and $self->checked 0 1 1
Condition33%1/3
$eol eq $self->{"MMB_eol"} and $self->checked
!ll&&!rl&&r
100
MC/DC0%0/2
$eol eq $self->{"MMB_eol"} and $self->checked
$eol eq $self->{"MMB_eol"} $self->checked
Truth table33%1/3
A and B
A= $eol eq $self->{"MMB_eol"}B= $self->checked
ABresult
0X0
100
111
188 1 my $lines = $self->lines;
189 1 ▶ if(@$lines)
Branch: 1 branch
BranchTrueFalseTotal
if (@$lines) 1 0 1
190 { # sometimes texts lack \n on last line
191 1 $lines->[-1] .= "\n";
192  
193  
194 1 ▶ if($eol eq 'CR') {s/[\015\012]+$/\015/ for @$lines}
Branch: 3 branches
BranchTrueFalseTotal
if ($eol eq 'CR') { } 0 1 1
elsif ($eol eq 'LF') { } 1 0 1
elsif ($eol eq 'CRLF') { } 0 0 0
195 1 elsif($eol eq 'LF') {s/[\015\012]+$/\012/ for @$lines}
196 0 elsif($eol eq 'CRLF') {s/[\015\012]+$/\015\012/ for @$lines}
197 else
198 0 { $self->log(WARNING => "Unknown line terminator $eol ignored");
199 0 return $self->eol('NATIVE');
200 }
201 }
202  
203 1 (ref $self)->new(based_on => $self, eol => $eol, data => $lines);
204 }
205  
206 #------------------------------------------
207  
208  
209 sub message(;$)
210 167 ▶{ my $self = shift;
Subroutine message: called CC=3 SCAR=11.0
Pod documented
211 167 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 156 11 167
212 156 ▶ { if($self->{MMB_message} = shift)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MMB_message"} = shift()) 156 0 156
213 156 { weaken $self->{MMB_message};
214 }
215 }
216 167 $self->{MMB_message};
217 }
218  
219  
220 sub isDelayed() {0}
221  
222  
223 sub isMultipart() {0}
224  
225  
226 sub isNested() {0}
227  
228  
229 sub partNumberOf($)
230 0 ▶{ shift->log(ERROR => 'part number needs multi-part or nested');
Subroutine partNumberOf: not called CC=1 SCAR=6.9
Pod documented
231 0 'ERROR';
232 }
233  
234 #------------------------------------------
235  
236  
237 sub type(;$)
238 1070 ▶{ my $self = shift;
Subroutine type: called CC=5 SCAR=16.1
Pod documented
239 1070 ▶ return $self->{MMB_type} if !@_ && defined $self->{MMB_type};
Branch: 1 branch
BranchTrueFalseTotal
if not @_ and defined $self->{"MMB_type"} 544 526 1070
Condition66%2/3
not @_ and defined $self->{"MMB_type"}
!ll&&!rl&&r
5260544
MC/DC50%1/2
not @_ and defined $self->{"MMB_type"}
not @_ defined $self->{"MMB_type"}
Truth table66%2/3
not(A) and B
A= not @_B= defined $self->{"MMB_type"}
ABresult
0X0
100
111
240  
241 526 delete $self->{MMB_mime};
242 526 ▶ my $type = shift // 'text/plain';
Condition100%2/2
shift() // "text/plain"
l!l
5206
MC/DC100%1/1
shift() // "text/plain"
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
243  
244 526 ▶ $self->{MMB_type} = ref $type ? $type->clone
Branch: 1 branch
BranchTrueFalseTotal
ref $type ? : 390 136 526
245 : Mail::Message::Field->new('Content-Type' => $type);
246 }
247  
248  
249 sub mimeType()
250 50 ▶{ my $self = shift;
Subroutine mimeType: called CC=5 SCAR=17.0
Pod documented
251 50 ▶ return $self->{MMB_mime} if exists $self->{MMB_mime};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"MMB_mime"} 20 30 50
252  
253 30 my $field = $self->{MMB_type};
254 30 ▶ my $body = defined $field ? $field->body : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $field ? : 30 0 30
255  
256 30 ▶ return $self->{MMB_mime} = $mime_plain
Branch: 1 branch
BranchTrueFalseTotal
unless length $body 0 30 30
257 unless length $body;
258  
259 $self->{MMB_mime}
260 30 ▶ = $mime_types->type($body) || MIME::Type->new(type => $body);
Condition33%1/3
$mime_types->type($body) || 'MIME::Type'->new('type', $body)
l!l&&r!l&&!r
3000
MC/DC0%0/2
$mime_types->type($body) || 'MIME::Type'->new('type', $body)
$mime_types->type($body) 'MIME::Type'->new('type', $body)
Truth table33%1/3
A || B
A= $mime_types->type($body)B= 'MIME::Type'->new('type', $body)
ABresult
1X1
011
000
261 }
262  
263  
264 66 ▶sub charset() { shift->type->attribute('charset') }
Subroutine charset: called CC=1 SCAR=0.0
Pod documented
265  
266  
267 sub transferEncoding(;$)
268 573 ▶{ my $self = shift;
Subroutine transferEncoding: called CC=5 SCAR=16.1
Pod documented
269 573 ▶ return $self->{MMB_transfer} if !@_ && defined $self->{MMB_transfer};
Branch: 1 branch
BranchTrueFalseTotal
if not @_ and defined $self->{"MMB_transfer"} 302 271 573
Condition100%3/3
not @_ and defined $self->{"MMB_transfer"}
!ll&&!rl&&r
21952302
MC/DC100%2/2
not @_ and defined $self->{"MMB_transfer"}
not @_ defined $self->{"MMB_transfer"}
Truth table100%3/3
not(A) and B
A= not @_B= defined $self->{"MMB_transfer"}
ABresult
0X0
100
111
270  
271 271 ▶ my $set = defined $_[0] ? shift : 'none';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 204 67 271
272 271 ▶ $self->{MMB_transfer} = ref $set ? $set->clone
Branch: 1 branch
BranchTrueFalseTotal
ref $set ? : 145 126 271
273 : Mail::Message::Field->new('Content-Transfer-Encoding' => $set);
274 }
275  
276  
277 sub description(;$)
278 396 ▶{ my $self = shift;
Subroutine description: called CC=5 SCAR=16.1
Pod documented
279 396 ▶ return $self->{MMB_description} if !@_ && $self->{MMB_description};
Branch: 1 branch
BranchTrueFalseTotal
if not @_ and $self->{"MMB_description"} 167 229 396
Condition100%3/3
not @_ and $self->{"MMB_description"}
!ll&&!rl&&r
17356167
MC/DC100%2/2
not @_ and $self->{"MMB_description"}
not @_ $self->{"MMB_description"}
Truth table100%3/3
not(A) and B
A= not @_B= $self->{"MMB_description"}
ABresult
0X0
100
111
280  
281 229 ▶ my $disp = defined $_[0] ? shift : 'none';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 137 92 229
282 229 ▶ $self->{MMB_description} = ref $disp ? $disp->clone
Branch: 1 branch
BranchTrueFalseTotal
ref $disp ? : 137 92 229
283 : Mail::Message::Field->new('Content-Description' => $disp);
284 }
285  
286  
287 sub disposition(;$)
288 398 ▶{ my $self = shift;
Subroutine disposition: called CC=5 SCAR=16.1
Pod documented
289 398 ▶ return $self->{MMB_disposition} if !@_ && $self->{MMB_disposition};
Branch: 1 branch
BranchTrueFalseTotal
if not @_ and $self->{"MMB_disposition"} 169 229 398
Condition100%3/3
not @_ and $self->{"MMB_disposition"}
!ll&&!rl&&r
17356169
MC/DC100%2/2
not @_ and $self->{"MMB_disposition"}
not @_ $self->{"MMB_disposition"}
Truth table100%3/3
not(A) and B
A= not @_B= $self->{"MMB_disposition"}
ABresult
0X0
100
111
290  
291 229 ▶ my $disp = defined $_[0] ? shift : 'none';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 135 94 229
292  
293 229 ▶ $self->{MMB_disposition} = ref $disp ? $disp->clone
Branch: 1 branch
BranchTrueFalseTotal
ref $disp ? : 135 94 229
294 : Mail::Message::Field->new('Content-Disposition' => $disp);
295 }
296  
297  
298 sub contentId(;$)
299 396 ▶{ my $self = shift;
Subroutine contentId: called CC=5 SCAR=16.1
Pod documented
300 396 ▶ return $self->{MMB_id} if !@_ && $self->{MMB_id};
Branch: 1 branch
BranchTrueFalseTotal
if not @_ and $self->{"MMB_id"} 167 229 396
Condition100%3/3
not @_ and $self->{"MMB_id"}
!ll&&!rl&&r
17356167
MC/DC100%2/2
not @_ and $self->{"MMB_id"}
not @_ $self->{"MMB_id"}
Truth table100%3/3
not(A) and B
A= not @_B= $self->{"MMB_id"}
ABresult
0X0
100
111
301  
302 229 ▶ my $cid = defined $_[0] ? shift : 'none';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 133 96 229
303 229 ▶ $self->{MMB_id} = ref $cid ? $cid->clone
Branch: 1 branch
BranchTrueFalseTotal
ref $cid ? : 133 96 229
304 : Mail::Message::Field->new('Content-ID' => $cid);
305 }
306  
307  
308 sub checked(;$)
309 114 ▶{ my $self = shift;
Subroutine checked: called CC=2 SCAR=6.9
Pod documented
310 114 ▶ @_ ? ($self->{MMB_checked} = shift) : $self->{MMB_checked};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 113 114
311 }
312  
313  
314 0 ▶sub nrLines(@) {shift->notImplemented}
Subroutine nrLines: not called CC=1 SCAR=6.9
Pod documented
315  
316  
317 0 ▶sub size(@) {shift->notImplemented}
Subroutine size: not called CC=1 SCAR=6.9
Pod documented
318  
319 #------------------------------------------
320  
321  
322 0 ▶sub string() {shift->notImplemented}
Subroutine string: not called CC=1 SCAR=6.9
Pod documented
323  
324 sub string_unless_carp()
325 25 ▶{ my $self = shift;
Subroutine string_unless_carp: called CC=2 SCAR=9.2
Pod undocumented
326 25 ▶ return $self->string unless (caller)[0] eq 'Carp';
Branch: 1 branch
BranchTrueFalseTotal
unless (caller)[0] eq "Carp" 25 0 25
327  
328 0 (my $class = ref $self) =~ s/^Mail::Message/MM/;
329 0 "$class object";
330 }
331  
332  
333 0 ▶sub lines() {shift->notImplemented}
Subroutine lines: not called CC=1 SCAR=6.9
Pod documented
334  
335  
336 0 ▶sub file(;$) {shift->notImplemented}
Subroutine file: not called CC=1 SCAR=6.9
Pod documented
337  
338  
339 0 ▶sub print(;$) {shift->notImplemented}
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
340  
341  
342 0 ▶sub printEscapedFrom($) {shift->notImplemented}
Subroutine printEscapedFrom: not called CC=1 SCAR=6.9
Pod documented
343  
344  
345 sub write(@)
346 0 ▶{ my ($self, %args) = @_;
Subroutine write: not called CC=4 SCAR=30.0
Pod documented
347 0 my $filename = $args{filename};
348 0 ▶ die "No filename for write() body" unless defined $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 0 0
349  
350 0 ▶ open OUT, '>', $filename or return;
Branch: 1 branch
BranchTrueFalseTotal
open OUT, ">", $filename or return 0 0 0
351 0 $self->print(\*OUT);
352 0 ▶ close OUT or return undef;
Branch: 1 branch
BranchTrueFalseTotal
close OUT or return undef 0 0 0
353 0 $self;
354 }
355  
356  
357 0 ▶sub endsOnNewline() {shift->notImplemented}
Subroutine endsOnNewline: not called CC=1 SCAR=6.9
Pod documented
358  
359  
360 0 ▶sub stripTrailingNewline() {shift->notImplemented}
Subroutine stripTrailingNewline: not called CC=1 SCAR=6.9
Pod documented
361  
362 #------------------------------------------
363  
364  
365 0 ▶sub read(@) {shift->notImplemented}
Subroutine read: not called CC=1 SCAR=6.9
Pod documented
366  
367  
368 sub contentInfoTo($)
369 90 ▶{ my ($self, $head) = @_;
Subroutine contentInfoTo: called CC=3 SCAR=11.1
Pod documented
370 90 ▶ return unless defined $head;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $head 0 90 90
371  
372 90 my $lines = $self->nrLines;
373 90 my $size = $self->size;
374 90 ▶ $size += $lines if $Mail::Message::crlf_platform;
Branch: 1 branch
BranchTrueFalseTotal
if $Mail::Message::crlf_platform 0 90 90
375  
376 90 $head->set($self->type);
377 90 $head->set($self->transferEncoding);
378 90 $head->set($self->disposition);
379 90 $head->set($self->description);
380 90 $head->set($self->contentId);
381 90 $self;
382 }
383  
384  
385 sub contentInfoFrom($)
386 40 ▶{ my ($self, $head) = @_;
Subroutine contentInfoFrom: called CC=4 SCAR=13.9
Pod documented
387  
388 40 $self->type($head->get('Content-Type', 0));
389  
390 my ($te, $disp, $desc, $cid)
391 40 ▶ = map { my $x = $head->get("Content-$_") || '';
Condition100%2/2
$head->get("Content-$_") || ''
l!l
31129
MC/DC100%1/1
$head->get("Content-$_") || ''
$head->get("Content-$_")
Truth table100%2/2
A
A= $head->get("Content-$_")
Aresult
11
00
392 160 s/^\s+//,s/\s+$// for $x;
393 160 ▶ length $x ? $x : undef
Branch: 1 branch
BranchTrueFalseTotal
length $x ? : 31 129 160
394 } qw/Transfer-Encoding Disposition Description ID/;
395  
396 40 $self->transferEncoding($te);
397 40 $self->disposition($disp);
398 40 $self->description($desc);
399 40 $self->contentId($cid);
400  
401 40 delete $self->{MMB_mime};
402 40 $self;
403  
404 }
405  
406  
407 sub modified(;$)
408 13 ▶{ my $self = shift;
Subroutine modified: called CC=2 SCAR=7.1
Pod documented
409 13 ▶ return $self->isModified unless @_; # compat 2.036
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 13 13
410 13 $self->{MMB_modified} = shift;
411 }
412  
413  
414 0 ▶sub isModified() { shift->{MMB_modified} }
Subroutine isModified: not called CC=1 SCAR=6.9
Pod documented
415  
416  
417 sub fileLocation(;@)
418 46 ▶{ my $self = shift;
Subroutine fileLocation: called CC=2 SCAR=6.9
Pod documented
419 46 ▶ return @$self{ qw/MMB_begin MMB_end/ } unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 7 39 46
420 39 @$self{ qw/MMB_begin MMB_end/ } = @_;
421 }
422  
423  
424 sub moveLocation($)
425 0 ▶{ my ($self, $dist) = @_;
Subroutine moveLocation: not called CC=1 SCAR=6.9
Pod documented
426 0 $self->{MMB_begin} -= $dist;
427 0 $self->{MMB_end} -= $dist;
428 0 $self;
429 }
430  
431  
432 2 ▶sub load() {shift}
Subroutine load: called CC=1 SCAR=0.0
Pod documented
433  
434 #------------------------------------------
435  
436  
437 34 my @in_encode = qw/check encode encoded eol isBinary isText unify
438 dispositionFilename/;
439 34 my %in_module = map { ($_ => 'encode') } @in_encode;
440  
441 sub AUTOLOAD(@)
442 15 ▶{ my $self = shift;
Subroutine AUTOLOAD: called CC=4 SCAR=13.9
443 15 our $AUTOLOAD;
444 15 (my $call = $AUTOLOAD) =~ s/.*\:\://g;
445  
446 15 ▶ my $mod = $in_module{$call} || 'construct';
Condition100%2/2
$in_module{$call} || 'construct'
l!l
123
MC/DC100%1/1
$in_module{$call} || 'construct'
$in_module{$call}
Truth table100%2/2
A
A= $in_module{$call}
Aresult
11
00
447 15 ▶ if($mod eq 'encode'){ require Mail::Message::Body::Encode }
Branch: 1 branch
BranchTrueFalseTotal
if ($mod eq 'encode') { } 12 3 15
448 3 else { require Mail::Message::Body::Construct }
449  
450 34 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
451 15 ▶ return $self->$call(@_) if $self->can($call); # now loaded
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($call) 15 0 15
452  
453 # AUTOLOAD inheritance is a pain
454 0 confess "Method $call() is not defined for a ", ref $self;
455 }
456  
457 #------------------------------------------
458  
459  
460 34 1;
« Box/Parser/Perl.pm ↑ Summary Message/Head/SpamGroup.pm »