Message/TransferEnc/EightBit.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 89.2% 50 / 56 CC 7 SCAR 14.7
CC
7
Cov
91%
encode
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« Message/Field/URIs.pm ↑ Summary Message/TransferEnc.pm »
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::TransferEnc::EightBit;{
13 8 our $VERSION = '4.05';
14 }
15  
16 8 ▶use parent 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 8 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #--------------------
24  
25 sub name() { '8bit' }
26  
27 sub check($@)
28 1 ▶{ my ($self, $body, %args) = @_;
Subroutine check: called CC=1 SCAR=0.0
Pod documented
29 1 $body;
30 }
31  
32 sub decode($@)
33 7 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: called CC=1 SCAR=0.0
Pod documented
34 7 $body->transferEncoding('none');
35 7 $body;
36 }
37  
38 sub encode($@)
39 32 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=7 SCAR=19.8
Pod documented
40  
41 32 my @lines;
42 32 my $changes = 0;
43  
44 32 foreach ($body->lines)
45 111 ▶ { $changes++ if s/[\000\013]//g;
Branch: 1 branch
BranchTrueFalseTotal
if s/[\000\013]//g 2 109 111
46  
47 # there shouldn't be any NL inside a line.
48 111 ▶ $changes++ if length > 997;
Branch: 1 branch
BranchTrueFalseTotal
if length $_ > 997 0 111 111
49 111 ▶ push @lines, substr($_, 0, 996, '')."\n"
Branch: 1 branch
BranchTrueFalseTotal
length $_ > 997 and do { push @lines, substr($_, 0, 996, "") . "\n" } 0 111 111
50 while length > 997;
51  
52 111 push @lines, $_;
53 }
54  
55 32 ▶ unless($changes)
Branch: 1 branch
BranchTrueFalseTotal
unless ($changes) 31 1 32
56 31 { $body->transferEncoding('8bit');
57 31 return $body;
58 }
59  
60 1 ▶ my $bodytype = $args{result_type} || ref $body;
Condition33%1/3
$args{'result_type'} || ref $body
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{'result_type'} || ref $body
$args{'result_type'} ref $body
Truth table33%1/3
A || B
A= $args{'result_type'}B= ref $body
ABresult
1X1
011
000
61 1 $bodytype->new(based_on => $body, transfer_encoding => '8bit', data => \@lines);
62 }
63  
64 8 1;
« Message/Field/URIs.pm ↑ Summary Message/TransferEnc.pm »