Message/Body/Multipart.pm

filter: Statementstmt 85.3% 198 / 232 Branchbran 69.2% 90 / 130 Conditioncond 58.6% 17 / 29 MC/DCmcdc 21.0% 4 / 19 Subroutinesub 79.4% 27 / 34 Podpod 91.3% 21 / 23 totaltotal 76.4% 357 / 467 CC 86 SCAR 23.5
CC
86
Cov
78%
init
20.7
read
17.3
print
14.9
CRAP 10.5
« Message/Head/Complete.pm ↑ Summary Message/Construct/Text.pm »
1 # Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message::Body::Multipart;
10 31 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 31 $VERSION = '3.012';
12  
13 31 ▶use base 'Mail::Message::Body';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 31 ▶use Mail::Message::Body::Lines;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 31 ▶use Mail::Message::Part;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 31 ▶use Mail::Box::FastScalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 31 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 sub init($)
26 34 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=19 SCAR=30.3
Pod undocumented
27 34 my $based = $args->{based_on};
28 34 ▶ $args->{mime_type} ||= defined $based ? $based->type : 'multipart/mixed';
Branch: 1 branch
BranchTrueFalseTotal
defined $based ? : 22 10 32
Condition66%2/3
$args->{"mime_type"} ||= defined $based ? $based->type : "multipart/mixed"
l!l&&r!l&&!r
2320
MC/DC0%0/2
$args->{"mime_type"} ||= defined $based ? $based->type : "multipart/mixed"
$args->{"mime_type"} defined $based ? $based->type : "multipart/mixed"
Truth table66%2/3
A ||= B
A= $args->{"mime_type"}B= defined $based ? $based->type : "multipart/mixed"
ABresult
1X1
011
000
29  
30 34 $self->SUPER::init($args);
31  
32 34 my @parts;
33 34 ▶ if($args->{parts})
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"parts"}) 30 4 34
34 30 { foreach my $raw (@{$args->{parts}})
35 52 ▶ { next unless defined $raw;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $raw 0 52 52
36 52 my $cooked = Mail::Message::Part->coerce($raw, $self);
37  
38 52 ▶ $self->log(ERROR => 'Data not convertible to a message (type is '
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cooked 0 52 52
39 , ref $raw,")\n"), next unless defined $cooked;
40  
41 52 push @parts, $cooked;
42 }
43 }
44  
45 34 my $preamble = $args->{preamble};
46 34 ▶ $preamble = Mail::Message::Body->new(data => $preamble)
Branch: 1 branch
BranchTrueFalseTotal
if defined $preamble and not ref $preamble 0 34 34
Condition66%2/3
defined $preamble and not ref $preamble
!ll&&!rl&&r
3130
MC/DC0%0/2
defined $preamble and not ref $preamble
defined $preamble not ref $preamble
Truth table66%2/3
A and not(B)
A= defined $preambleB= not ref $preamble
ABresult
0X0
100
111
47 if defined $preamble && ! ref $preamble;
48
49 34 my $epilogue = $args->{epilogue};
50 34 ▶ $epilogue = Mail::Message::Body->new(data => $epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if defined $epilogue and not ref $epilogue 0 34 34
Condition66%2/3
defined $epilogue and not ref $epilogue
!ll&&!rl&&r
3130
MC/DC0%0/2
defined $epilogue and not ref $epilogue
defined $epilogue not ref $epilogue
Truth table66%2/3
A and not(B)
A= defined $epilogueB= not ref $epilogue
ABresult
0X0
100
111
51 if defined $epilogue && ! ref $epilogue;
52
53 34 ▶ if($based)
Branch: 1 branch
BranchTrueFalseTotal
if ($based) { } 22 12 34
54 22 ▶ { $self->boundary($args->{boundary} || $based->boundary);
Condition33%1/3
$args->{'boundary'} || $based->boundary
l!l&&r!l&&!r
0220
MC/DC0%0/2
$args->{'boundary'} || $based->boundary
$args->{'boundary'} $based->boundary
Truth table33%1/3
A || B
A= $args->{'boundary'}B= $based->boundary
ABresult
1X1
011
000
55 $self->{MMBM_preamble}
56 22 ▶ = defined $preamble ? $preamble : $based->preamble;
Branch: 1 branch
BranchTrueFalseTotal
defined $preamble ? : 3 19 22
57  
58 $self->{MMBM_parts}
59 = @parts ? \@parts
60 22 ▶ : !$args->{parts} && $based->isMultipart
Branch: 2 branches
BranchTrueFalseTotal
@parts ? : 19 3 22
!$args->{'parts'} && $based->isMultipart ? : 1 2 3
Condition66%2/3
not $args->{"parts"} and $based->isMultipart
!ll&&!rl&&r
201
MC/DC50%1/2
not $args->{"parts"} and $based->isMultipart
not $args->{"parts"} $based->isMultipart
Truth table66%2/3
not(A) and B
A= not $args->{"parts"}B= $based->isMultipart
ABresult
0X0
100
111
61 ? [ $based->parts('ACTIVE') ]
62 : [];
63  
64 $self->{MMBM_epilogue}
65 22 ▶ = defined $epilogue ? $epilogue : $based->epilogue;
Branch: 1 branch
BranchTrueFalseTotal
defined $epilogue ? : 3 19 22
66 }
67 else
68 12 ▶ { $self->boundary($args->{boundary} ||$self->type->attribute('boundary'));
Condition66%2/3
$args->{'boundary'} || $self->type->attribute('boundary')
l!l&&r!l&&!r
1011
MC/DC50%1/2
$args->{'boundary'} || $self->type->attribute('boundary')
$args->{'boundary'} $self->type->attribute('boundary')
Truth table66%2/3
A || B
A= $args->{'boundary'}B= $self->type->attribute('boundary')
ABresult
1X1
011
000
69 12 $self->{MMBM_preamble} = $preamble;
70 12 $self->{MMBM_parts} = \@parts;
71 12 $self->{MMBM_epilogue} = $epilogue;
72 }
73  
74 34 $self;
75 }
76  
77 sub isMultipart() {1}
78  
79 # A multipart body is never binary itself. The parts may be.
80 sub isBinary() {0}
81  
82 sub clone()
83 2 ▶{ my $self = shift;
Subroutine clone: called CC=3 SCAR=11.0
Pod documented
84 2 my $preamble = $self->preamble;
85 2 my $epilogue = $self->epilogue;
86  
87 my $body = ref($self)->new
88 ( $self->logSettings
89 , based_on => $self
90 , preamble => ($preamble ? $preamble->clone : undef)
91 , epilogue => ($epilogue ? $epilogue->clone : undef)
92 2 ▶ , parts => [ map {$_->clone} $self->parts('ACTIVE') ]
Branch: 2 branches
BranchTrueFalseTotal
$preamble ? : 1 1 2
$epilogue ? : 1 1 2
93 );
94  
95 }
96  
97 sub nrLines()
98 21 ▶{ my $self = shift;
Subroutine nrLines: called CC=6 SCAR=17.9
Pod documented
99 21 my $nr = 1; # trailing part-sep
100  
101 21 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 1 20 21
102 1 { $nr += $preamble->nrLines;
103 1 ▶ $nr++ if $preamble->endsOnNewline;
Branch: 1 branch
BranchTrueFalseTotal
if $preamble->endsOnNewline 1 0 1
104 }
105  
106 21 foreach my $part ($self->parts('ACTIVE'))
107 31 { $nr += 1 + $part->nrLines;
108 31 ▶ $nr++ if $part->body->endsOnNewline;
Branch: 1 branch
BranchTrueFalseTotal
if $part->body->endsOnNewline 29 2 31
109 }
110  
111 21 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 1 20 21
112 1 { $nr += $epilogue->nrLines;
113 }
114  
115 21 $nr;
116 }
117  
118 sub size()
119 25 ▶{ my $self = shift;
Subroutine size: called CC=4 SCAR=13.9
Pod documented
120 25 my $bbytes = length($self->boundary) +4; # \n--$b\n
121  
122 25 my $bytes = $bbytes +2; # last boundary, \n--$b--\n
123 25 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) { } 4 21 25
124 4 { $bytes += $preamble->size }
125 21 else { $bytes -= 1 } # no leading \n
126  
127 25 $bytes += $bbytes + $_->size foreach $self->parts('ACTIVE');
128 25 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 1 24 25
129 1 { $bytes += $epilogue->size;
130 }
131 25 $bytes;
132 }
133  
134 4 ▶sub string() { join '', shift->lines }
Subroutine string: called CC=1 SCAR=0.0
Pod documented
135  
136 sub lines()
137 4 ▶{ my $self = shift;
Subroutine lines: called CC=9 SCAR=24.4
Pod documented
138  
139 4 my $boundary = $self->boundary;
140 4 my @lines;
141  
142 4 my $preamble = $self->preamble;
143 4 ▶ push @lines, $preamble->lines if $preamble;
Branch: 1 branch
BranchTrueFalseTotal
if $preamble 0 4 4
144  
145 4 foreach my $part ($self->parts('ACTIVE'))
146 { # boundaries start with \n
147 8 ▶ if(!@lines) { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (not @lines) { } 4 4 8
elsif ($lines[-1] =~ /\n$/) { } 4 0 4
148 4 elsif($lines[-1] =~ m/\n$/) { push @lines, "\n" }
149 0 else { $lines[-1] .= "\n" }
150 8 push @lines, "--$boundary\n", $part->lines;
151 }
152  
153 4 ▶ if(!@lines) { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (not @lines) { } 0 4 4
elsif ($lines[-1] =~ /\n$/) { } 4 0 4
154 4 elsif($lines[-1] =~ m/\n$/) { push @lines, "\n" }
155 0 else { $lines[-1] .= "\n" }
156 4 push @lines, "--$boundary--";
157  
158 4 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 0 4 4
159 0 { $lines[-1] .= "\n";
160 0 push @lines, $epilogue->lines;
161 }
162  
163 4 ▶ wantarray ? @lines : \@lines;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 0 4
164 }
165  
166 sub file() # It may be possible to speed-improve the next
167 0 ▶{ my $self = shift; # code, which first produces a full print of
Subroutine file: not called CC=1 SCAR=6.9
Pod documented
168 0 my $text; # the message in memory...
169 0 my $dump = Mail::Box::FastScalar->new(\$text);
170 0 $self->print($dump);
171 0 $dump->seek(0,0);
172 0 $dump;
173 }
174  
175 sub print(;$)
176 8 ▶{ my $self = shift;
Subroutine print: called CC=11 SCAR=27.0
Pod documented
177 8 ▶ my $out = shift || select;
Condition33%1/3
shift() || select()
l!l&&r!l&&!r
800
MC/DC0%0/2
shift() || select()
shift() select()
Truth table33%1/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
178  
179 8 my $boundary = $self->boundary;
180 8 my $count = 0;
181 8 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 2 6 8
182 2 { $preamble->print($out);
183 2 $count++;
184 }
185  
186 8 ▶ if(ref $out eq 'GLOB')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $out eq 'GLOB') { } 0 8 8
187 0 { foreach my $part ($self->parts('ACTIVE'))
188 0 ▶ { print $out "\n" if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 0 0 0
189 0 print $out "--$boundary\n";
190 0 $part->print($out);
191 }
192 0 ▶ print $out "\n" if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 0 0 0
193 0 print $out "--$boundary--";
194 }
195 else
196 8 { foreach my $part ($self->parts('ACTIVE'))
197 13 ▶ { $out->print("\n") if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 9 4 13
198 13 $out->print("--$boundary\n");
199 13 $part->print($out);
200 }
201 8 ▶ $out->print("\n") if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 6 2 8
202 8 $out->print("--$boundary--");
203 }
204  
205 8 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 2 6 8
206 2 { $out->print("\n");
207 2 $epilogue->print($out);
208 }
209  
210 8 $self;
211 }
212  
213  
214 sub foreachLine($)
215 0 ▶{ my ($self, $code) = @_;
Subroutine foreachLine: not called CC=1 SCAR=6.9
Pod documented
216 0 $self->log(ERROR => "You cannot use foreachLine on a multipart");
217 0 confess;
218 }
219  
220 sub check()
221 0 ▶{ my $self = shift;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
222 0 ▶ $self->foreachComponent( sub {$_[1]->check} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
223 }
224  
225 sub encode(@)
226 0 ▶{ my ($self, %args) = @_;
Subroutine encode: not called CC=1 SCAR=6.9
Pod documented
227 0 ▶ $self->foreachComponent( sub {$_[1]->encode(%args)} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
228 }
229  
230 sub encoded()
231 19 ▶{ my $self = shift;
Subroutine encoded: called CC=1 SCAR=0.0
Pod documented
232 19 ▶ $self->foreachComponent( sub {$_[1]->encoded} );
Subroutine __ANON__: called CC=1 SCAR=0.0
233 }
234  
235 sub read($$$$)
236 2 ▶{ my ($self, $parser, $head, $bodytype) = @_;
Subroutine read: called CC=15 SCAR=28.5
Pod documented
237  
238 2 my $boundary = $self->boundary;
239  
240 2 $parser->pushSeparator("--$boundary");
241 2 my @msgopts = $self->logSettings;
242  
243 2 my $te;
244 2 ▶ $te = lc $1
Branch: 1 branch
BranchTrueFalseTotal
if ($head->get("Content-Transfer-Encoding") || "") =~ /(\w+)/ 1 1 2
Condition100%2/2
$head->get('Content-Transfer-Encoding') || ''
l!l
11
MC/DC100%1/1
$head->get('Content-Transfer-Encoding') || ''
$head->get('Content-Transfer-Encoding')
Truth table100%2/2
A
A= $head->get('Content-Transfer-Encoding')
Aresult
11
00
245 if +($head->get('Content-Transfer-Encoding') || '') =~ m/(\w+)/;
246
247 2 my @sloppyopts =
248 ( mime_type => 'text/plain'
249 , transfer_encoding => $te
250 );
251  
252 # Get preamble.
253 2 my $headtype = ref $head;
254  
255 2 my $begin = $parser->filePosition;
256 2 my $preamble = Mail::Message::Body::Lines->new(@msgopts, @sloppyopts)
257 ->read($parser, $head);
258  
259 2 ▶ $preamble->nrLines
Branch: 1 branch
BranchTrueFalseTotal
$preamble->nrLines or undef $preamble 1 1 2
260 or undef $preamble;
261  
262 2 ▶ $self->{MMBM_preamble} = $preamble
Branch: 1 branch
BranchTrueFalseTotal
if defined $preamble 1 1 2
263 if defined $preamble;
264  
265 # Get the parts.
266  
267 2 my @parts;
268 2 ▶ while(my $sep = $parser->readSeparator)
Branch: 1 branch
BranchTrueFalseTotal
if (my $sep = $parser->readSeparator) 6 0 6
269 6 ▶ { last if $sep eq "--$boundary--\n";
Branch: 1 branch
BranchTrueFalseTotal
if $sep eq "--$boundary--\n" 2 4 6
270  
271 4 my $part = Mail::Message::Part->new
272 ( @msgopts
273 , container => $self
274 );
275  
276 4 ▶ last unless $part->readFromParser($parser, $bodytype);
Branch: 1 branch
BranchTrueFalseTotal
unless $part->readFromParser($parser, $bodytype) 0 4 4
277 4 ▶ push @parts, $part
Branch: 1 branch
BranchTrueFalseTotal
if $part->head->names or $part->body->size 4 0 4
Condition33%1/3
$part->head->names or $part->body->size
l!l&&r!l&&!r
400
MC/DC0%0/2
$part->head->names or $part->body->size
$part->head->names $part->body->size
Truth table33%1/3
A or B
A= $part->head->namesB= $part->body->size
ABresult
1X1
011
000
278 if $part->head->names || $part->body->size;
279 }
280 2 $self->{MMBM_parts} = \@parts;
281  
282 # Get epilogue
283  
284 2 $parser->popSeparator;
285 2 my $epilogue = Mail::Message::Body::Lines->new(@msgopts, @sloppyopts)
286 ->read($parser, $head);
287  
288 2 ▶ my $end = defined $epilogue ? ($epilogue->fileLocation)[1]
Branch: 3 branches
BranchTrueFalseTotal
defined $epilogue ? : 2 0 2
@parts ? : 0 0 0
defined $preamble ? : 0 0 0
289 : @parts ? ($parts[-1]->body->fileLocation)[1]
290 : defined $preamble ? ($preamble->fileLocation)[1]
291 : $begin;
292 2 $self->fileLocation($begin, $end);
293  
294 2 ▶ $epilogue->nrLines
Branch: 1 branch
BranchTrueFalseTotal
$epilogue->nrLines or undef $epilogue 2 0 2
295 or undef $epilogue;
296  
297 2 ▶ $self->{MMBM_epilogue} = $epilogue
Branch: 1 branch
BranchTrueFalseTotal
if defined $epilogue 0 2 2
298 if defined $epilogue;
299  
300 2 $self;
301 }
302  
303 #------------------------------------------
304  
305  
306 sub foreachComponent($)
307 19 ▶{ my ($self, $code) = @_;
Subroutine foreachComponent: called CC=10 SCAR=23.0
Pod documented
308 19 my $changes = 0;
309  
310 19 my $new_preamble;
311 19 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 1 18 19
312 1 { $new_preamble = $code->($self, $preamble);
313 1 ▶ $changes++ unless $preamble == $new_preamble;
Branch: 1 branch
BranchTrueFalseTotal
unless $preamble == $new_preamble 0 1 1
314 }
315  
316 19 my $new_epilogue;
317 19 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 1 18 19
318 1 { $new_epilogue = $code->($self, $epilogue);
319 1 ▶ $changes++ unless $epilogue == $new_epilogue;
Branch: 1 branch
BranchTrueFalseTotal
unless $epilogue == $new_epilogue 1 0 1
320 }
321  
322 19 my @new_bodies;
323 19 foreach my $part ($self->parts('ACTIVE'))
324 30 { my $part_body = $part->body;
325 30 my $new_body = $code->($self, $part_body);
326  
327 30 ▶ $changes++ if $new_body != $part_body;
Branch: 1 branch
BranchTrueFalseTotal
if $new_body != $part_body 13 17 30
328 30 push @new_bodies, [$part, $new_body];
329 }
330  
331 19 ▶ return $self unless $changes;
Branch: 1 branch
BranchTrueFalseTotal
unless $changes 10 9 19
332  
333 9 my @new_parts;
334 9 foreach (@new_bodies)
335 19 { my ($part, $body) = @$_;
336 19 my $new_part = Mail::Message::Part->new
337 ( head => $part->head->clone,
338 container => undef
339 );
340 19 $new_part->body($body);
341 19 push @new_parts, $new_part;
342 }
343  
344 9 my $constructed = (ref $self)->new
345 ( preamble => $new_preamble
346 , parts => \@new_parts
347 , epilogue => $new_epilogue
348 , based_on => $self
349 );
350  
351 $_->container($constructed)
352 9 foreach @new_parts;
353  
354 9 $constructed;
355 }
356  
357  
358 sub attach(@)
359 2 ▶{ my $self = shift;
Subroutine attach: called CC=1 SCAR=0.0
Pod documented
360 2 my $new = ref($self)->new
361 ( based_on => $self
362 , parts => [$self->parts, @_]
363 );
364 }
365  
366  
367 sub stripSignature(@)
368 1 ▶{ my $self = shift;
Subroutine stripSignature: called CC=2 SCAR=7.0
Pod documented
369  
370 1 my @allparts = $self->parts;
371 1 my @parts = grep {! $_->body->mimeType->isSignature} @allparts;
372  
373 1 ▶ @allparts==@parts ? $self
Branch: 1 branch
BranchTrueFalseTotal
@allparts == @parts ? : 0 1 1
374 : (ref $self)->new(based_on => $self, parts => \@parts);
375 }
376  
377 #------------------------------------------
378  
379  
380 100 ▶sub preamble() {shift->{MMBM_preamble}}
Subroutine preamble: called CC=1 SCAR=0.0
Pod documented
381  
382  
383 100 ▶sub epilogue() {shift->{MMBM_epilogue}}
Subroutine epilogue: called CC=1 SCAR=0.0
Pod documented
384  
385  
386 sub parts(;$)
387 151 ▶{ my $self = shift;
Subroutine parts: called CC=7 SCAR=23.0
Pod documented
388 151 ▶ return @{$self->{MMBM_parts}} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 65 86 151
389  
390 86 my $what = shift;
391 86 my @parts = @{$self->{MMBM_parts}};
392  
393 0 ▶ $what eq 'RECURSE' ? (map {$_->parts('RECURSE')} @parts)
Branch: 2 branches
BranchTrueFalseTotal
$what eq 'ALL' ? : 0 86 86
$what eq 'DELETED' ? : 0 86 86
394 : $what eq 'ALL' ? @parts
395 0 ▶ : $what eq 'DELETED' ? (grep {$_->isDeleted} @parts)
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'ACTIVE' ? : 86 0 86
396 144 ▶ : $what eq 'ACTIVE' ? (grep {not $_->isDeleted} @parts)
Branch: 1 branch
BranchTrueFalseTotal
ref $what eq 'CODE' ? : 0 0 0
397 86 ▶ : ref $what eq 'CODE'? (grep {$what->($_)} @parts)
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'RECURSE' ? : 0 86 86
398 : ($self->log(ERROR => "Unknown criterium $what to select parts."), return ());
399 }
400  
401  
402 12 ▶sub part($) { shift->{MMBM_parts}[shift] }
Subroutine part: called CC=1 SCAR=0.0
Pod documented
403  
404 sub partNumberOf($)
405 6 ▶{ my ($self, $part) = @_;
Subroutine partNumberOf: called CC=5 SCAR=18.1
Pod documented
406 6 my @parts = $self->parts('ACTIVE');
407 6 my $msg = $self->message;
408 6 ▶ unless($msg)
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 0 6 6
409 0 { $self->log(ERROR => 'multipart is not connected');
410 0 return 'ERROR';
411 }
412 6 ▶ my $base = $msg->isa('Mail::Message::Part') ? $msg->partNumber.'.' : '';
Branch: 1 branch
BranchTrueFalseTotal
$msg->isa('Mail::Message::Part') ? : 0 6 6
413 6 foreach my $partnr (0..@parts)
414 12 ▶ { return $base.($partnr+1)
Branch: 1 branch
BranchTrueFalseTotal
if $parts[$partnr] == $part 6 6 12
415 if $parts[$partnr] == $part;
416 }
417 0 $self->log(ERROR => 'multipart is not found or not active');
418 0 'ERROR';
419 }
420  
421  
422 sub boundary(;$)
423 98 ▶{ my $self = shift;
Subroutine boundary: called CC=5 SCAR=16.2
Pod documented
424 98 my $mime = $self->type;
425  
426 98 ▶ unless(@_)
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 63 35 98
427 63 { my $boundary = $mime->attribute('boundary');
428 63 ▶ return $boundary if defined $boundary;
Branch: 1 branch
BranchTrueFalseTotal
if defined $boundary 63 0 63
429 }
430  
431 35 ▶ my $boundary = @_ && defined $_[0] ? (shift) : "boundary-".int rand(1000000);
Branch: 1 branch
BranchTrueFalseTotal
@_ && defined $_[0] ? : 24 11 35
Condition66%2/3
@_ and defined $_[0]
!ll&&!rl&&r
01124
MC/DC50%1/2
@_ and defined $_[0]
@_ defined $_[0]
Truth table66%2/3
A and B
A= @_B= defined $_[0]
ABresult
0X0
100
111
432 35 $self->type->attribute(boundary => $boundary);
433 }
434  
435 sub endsOnNewline() { 1 }
436  
437 0 ▶sub toplevel() { my $msg = shift->message; $msg ? $msg->toplevel : undef}
Subroutine toplevel: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$msg ? : 0 0 0
438  
439 #-------------------------------------------
440  
441  
442 31 1;
« Message/Head/Complete.pm ↑ Summary Message/Construct/Text.pm »