Message/TransferEnc/SevenBit.pm

filter: Statementstmt 80.0% 28 / 35 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 73.3% 44 / 60 CC 8 SCAR 17.4
CC
8
Cov
75%
encode
9.0
check
2.0
decode
2.0
CRAP 5.7
« Message/Field.pm ↑ Summary Message/Body/File.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::SevenBit;{
13 3 our $VERSION = '4.05';
14 }
15  
16 3 ▶use parent 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 3 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #--------------------
24  
25 sub name() { '7bit' }
26  
27 sub check($@)
28 0 ▶{ my ($self, $body, %args) = @_;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
29 0 $body;
30 }
31  
32 sub decode($@)
33 0 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: not called CC=1 SCAR=6.9
Pod documented
34 0 $body->transferEncoding('none');
35 0 $body;
36 }
37  
38 sub encode($@)
39 2 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=8 SCAR=22.0
Pod documented
40  
41 2 my @lines;
42 2 my $changes = 0;
43  
44 2 foreach ($body->lines)
45 4 ▶ { $changes++ if s/([^\000-\127])/chr(ord($1) & 0x7f)/ge;
Branch: 1 branch
BranchTrueFalseTotal
if s/([^\000-\127])/chr(ord $1 & 127);/eg 4 0 4
46 4 ▶ $changes++ if s/[\000\013]//g;
Branch: 1 branch
BranchTrueFalseTotal
if s/[\000\013]//g 2 2 4
47  
48 4 ▶ $changes++ if length > 997;
Branch: 1 branch
BranchTrueFalseTotal
if length $_ > 997 0 4 4
49 4 ▶ push @lines, substr($_, 0, 996, '')."\n"
Branch: 1 branch
BranchTrueFalseTotal
length $_ > 997 and do { push @lines, substr($_, 0, 996, "") . "\n" } 0 4 4
50 while length > 997;
51  
52 4 push @lines, $_;
53 }
54  
55 2 ▶ unless($changes)
Branch: 1 branch
BranchTrueFalseTotal
unless ($changes) 0 2 2
56 0 { $body->transferEncoding('7bit');
57 0 return $body;
58 }
59  
60 2 ▶ my $bodytype = $args{result_type} || ref $body;
Condition66%2/3
$args{'result_type'} || ref $body
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{'result_type'} || ref $body
$args{'result_type'} ref $body
Truth table66%2/3
A || B
A= $args{'result_type'}B= ref $body
ABresult
1X1
011
000
61 2 $bodytype->new(based_on => $body, transfer_encoding => '7bit', data => \@lines);
62 }
63  
64 3 1;
« Message/Field.pm ↑ Summary Message/Body/File.pm »