Message/Body/Encode.pm

filter: Statementstmt 72.5% 116 / 160 Branchbran 60.7% 62 / 102 Conditioncond 58.9% 46 / 78 MC/DCmcdc 25.5% 12 / 47 Subroutinesub 85.0% 17 / 20 Podpod 100% 9 / 9 totaltotal 62.9% 262 / 416 CC 80 SCAR 37.0
CC
80
Cov
66%
dispositionFilename
72.1
encode
59.5
unify
20.0
CRAP 40.6
« Message/Replace/MailInternet.pm ↑ Summary Message/Head/SpamGroup.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;
10 12 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 $VERSION = '3.012';
12  
13 12 ▶use base 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use MIME::Types ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use Encode 'find_encoding';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 12 ▶use Mail::Message::Field ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 12 ▶use Mail::Message::Field::Full ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # http://www.iana.org/assignments/character-sets
27 12 ▶use Encode::Alias;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 12 define_alias(qr/^unicode-?1-?1-?utf-?([78])$/i => '"UTF-$1"'); # rfc1642
29  
30 12 my $mime_types;
31  
32  
33 sub encode(@)
34 66 ▶{ my ($self, %args) = @_;
Subroutine encode: called CC=38 SCAR=40.9
Pod documented
35  
36 # simplify the arguments
37 66 my $type_from = $self->type;
38 66 ▶ my $type_to = $args{mime_type} || $type_from->clone->study;
Condition33%1/3
$args{'mime_type'} || $type_from->clone->study
l!l&&r!l&&!r
0660
MC/DC0%0/2
$args{'mime_type'} || $type_from->clone->study
$args{'mime_type'} $type_from->clone->study
Truth table33%1/3
A || B
A= $args{'mime_type'}B= $type_from->clone->study
ABresult
1X1
011
000
39 66 ▶ $type_to = Mail::Message::Field::Full->new('Content-Type' => $type_to)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $type_to 0 66 66
40 unless ref $type_to;
41  
42 66 ▶ my $transfer = $args{transfer_encoding} || $self->transferEncoding->clone;
Condition66%2/3
$args{'transfer_encoding'} || $self->transferEncoding->clone
l!l&&r!l&&!r
6510
MC/DC0%0/2
$args{'transfer_encoding'} || $self->transferEncoding->clone
$args{'transfer_encoding'} $self->transferEncoding->clone
Truth table66%2/3
A || B
A= $args{'transfer_encoding'}B= $self->transferEncoding->clone
ABresult
1X1
011
000
43 66 ▶ $transfer = Mail::Message::Field->new('Content-Transfer-Encoding'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $transfer 63 3 66
44 => $transfer) unless ref $transfer;
45  
46 66 my $trans_was = lc $self->transferEncoding;
47 66 my $trans_to = lc $transfer;
48  
49 66 my ($char_was, $char_to, $from, $to);
50 66 ▶ if($type_from =~ m!^text/!i)
Branch: 1 branch
BranchTrueFalseTotal
if ($type_from =~ m[^text/]i) 63 3 66
51 63 ▶ { $char_was = $type_from->attribute('charset') || 'us-ascii';
Condition50%1/2
$type_from->attribute('charset') || 'us-ascii'
l!l
630
MC/DC0%0/1
$type_from->attribute('charset') || 'us-ascii'
$type_from->attribute('charset')
Truth table50%1/2
A
A= $type_from->attribute('charset')
Aresult
11
00
52 63 $char_to = $type_to->attribute('charset');
53  
54 63 ▶ if(my $charset = delete $args{charset})
Branch: 2 branches
BranchTrueFalseTotal
if (my $charset = delete $args{'charset'}) { } 59 4 63
elsif (not $char_to) { } 0 4 4
55 59 ▶ { if(!$char_to || $char_to ne $charset)
Branch: 1 branch
BranchTrueFalseTotal
if (not $char_to or $char_to ne $charset) 39 20 59
Condition66%2/3
not $char_to or $char_to ne $charset
l!l&&r!l&&!r
03920
MC/DC50%1/2
not $char_to or $char_to ne $charset
not $char_to $char_to ne $charset
Truth table66%2/3
not(A) or B
A= not $char_toB= $char_to ne $charset
ABresult
1X1
011
000
56 39 { $char_to = $charset;
57 39 $type_to->attribute(charset => $char_to);
58 }
59 }
60 elsif(!$char_to)
61 0 { $char_to = 'utf8';
62 0 $type_to->attribute(charset => $char_to);
63 }
64  
65 63 ▶ if($char_was ne 'PERL')
Branch: 1 branch
BranchTrueFalseTotal
if ($char_was ne "PERL") 13 50 63
66 13 ▶ { $from = find_encoding $char_was
Branch: 1 branch
BranchTrueFalseTotal
$from = &find_encoding($char_was) or $self->log("WARNING", "Charset `${char_was}' is not known.") 0 13 13
67 or $self->log(WARNING => "Charset `$char_was' is not known.");
68 }
69 63 ▶ if($char_to ne 'PERL')
Branch: 1 branch
BranchTrueFalseTotal
if ($char_to ne "PERL") 34 29 63
70 34 ▶ { $to = find_encoding $char_to
Branch: 1 branch
BranchTrueFalseTotal
$to = &find_encoding($char_to) or $self->log("WARNING", "Charset `${char_to}' is not known.") 0 34 34
71 or $self->log(WARNING => "Charset `$char_to' is not known.");
72 }
73  
74 63 ▶ if($trans_to ne 'none' && $char_to eq 'PERL')
Branch: 1 branch
BranchTrueFalseTotal
if ($trans_to ne "none" and $char_to eq "PERL") 0 63 63
Condition66%2/3
$trans_to ne "none" and $char_to eq "PERL"
!ll&&!rl&&r
30330
MC/DC0%0/2
$trans_to ne "none" and $char_to eq "PERL"
$trans_to ne "none" $char_to eq "PERL"
Truth table66%2/3
A and B
A= $trans_to ne "none"B= $char_to eq "PERL"
ABresult
0X0
100
111
75 { # We cannot leave the body into the 'PERL' charset when transfer-
76 # encoding is applied.
77 0 $self->log(WARNING => "Transfer-Encoding `$trans_to' requires "
78 . "explicit charset, defaulted to utf8");
79 0 $char_to = 'utf8';
80 }
81 }
82  
83  
84 # Any changes to be made?
85 66 ▶ if($trans_was eq $trans_to)
Branch: 1 branch
BranchTrueFalseTotal
if ($trans_was eq $trans_to) 25 41 66
86 25 ▶ { return $self if !$from && !$to;
Branch: 1 branch
BranchTrueFalseTotal
unless $from or $to 19 6 25
Condition100%3/3
$from or $to
l!l&&r!l&&!r
4219
MC/DC100%2/2
$from or $to
$from $to
Truth table100%3/3
A or B
A= $fromB= $to
ABresult
1X1
011
000
87 6 ▶ if($from && $to && $from->name eq $to->name)
Branch: 1 branch
BranchTrueFalseTotal
if ($from and $to and $from->name eq $to->name) 0 6 6
Condition50%3/6
$from and $to and $from->name eq $to->name
!ll&&!rl&&r
600
$from and $to
!ll&&!rl&&r
240
MC/DC0%0/3
$from and $to and $from->name eq $to->name
$from $to $from->name eq $to->name
Truth table50%2/4
A and B and C
A= $fromB= $toC= $from->name eq $to->name
ABCresult
0XX0
10X0
1100
1111
88 { # modify charset into an alias, if requested
89 0 ▶ $self->charset($char_to) if $char_was ne $char_to;
Branch: 1 branch
BranchTrueFalseTotal
if $char_was ne $char_to 0 0 0
90 0 return $self;
91 }
92 }
93  
94 47 ▶ my $bodytype = $args{result_type} || ref $self;
Condition33%1/3
$args{'result_type'} || ref $self
l!l&&r!l&&!r
0470
MC/DC0%0/2
$args{'result_type'} || ref $self
$args{'result_type'} ref $self
Truth table33%1/3
A || B
A= $args{'result_type'}B= ref $self
ABresult
1X1
011
000
95  
96 47 my $decoded;
97 47 ▶ if($trans_was eq 'none')
Branch: 2 branches
BranchTrueFalseTotal
if ($trans_was eq 'none') { } 38 9 47
elsif (my $decoder = $self->getTransferEncHandler($trans_was)) { } 9 0 9
98 38 { $decoded = $self }
99 elsif(my $decoder = $self->getTransferEncHandler($trans_was))
100 9 { $decoded = $decoder->decode($self, result_type => $bodytype) }
101 else
102 0 { $self->log(WARNING =>
103 "No decoder defined for transfer encoding $trans_was.");
104 0 return $self;
105 }
106  
107 47 ▶ my $new_data
Branch: 3 branches
BranchTrueFalseTotal
$to && $char_was eq 'PERL' ? : 30 17 47
$from && $char_to eq 'PERL' ? : 9 8 17
$to && $from && $from->name ne $to->name ? : 0 8 8
Condition83%10/12
$to and $char_was eq "PERL"
!ll&&!rl&&r
13430
$from and $char_to eq "PERL"
!ll&&!rl&&r
449
$to and $from and $from->name ne $to->name
!ll&&!rl&&r
440
$to and $from
!ll&&!rl&&r
404
MC/DC100%2/2
$to and $char_was eq "PERL"
$to $char_was eq "PERL"
MC/DC100%2/2
$from and $char_to eq "PERL"
$from $char_to eq "PERL"
MC/DC0%0/3
$to and $from and $from->name ne $to->name
$to $from $from->name ne $to->name
Truth table100%3/3
A and B
A= $toB= $char_was eq "PERL"
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $fromB= $char_to eq "PERL"
ABresult
0X0
100
111
Truth table50%2/4
A and B and C
A= $toB= $fromC= $from->name ne $to->name
ABCresult
0XX0
10X0
1100
1111
108 = $to && $char_was eq 'PERL' ? $to->encode($decoded->string)
109 : $from && $char_to eq 'PERL' ? $from->decode($decoded->string)
110 : $to && $from && $from->name ne $to->name
111 ? $to->encode($from->decode($decoded->string))
112 : undef;
113  
114 47 ▶ my $recoded = $new_data ? $bodytype->new(based_on => $decoded
Branch: 1 branch
BranchTrueFalseTotal
$new_data ? : 39 8 47
115 , data => $new_data, mime_type => $type_to, checked => 1) : $decoded;
116  
117 47 my $trans;
118 47 ▶ if($trans_to ne 'none')
Branch: 1 branch
BranchTrueFalseTotal
if ($trans_to ne "none") 36 11 47
119 36 ▶ { $trans = $self->getTransferEncHandler($trans_to)
Branch: 1 branch
BranchTrueFalseTotal
$trans = $self->getTransferEncHandler($trans_to) or $self->log("WARNING", "No encoder defined for transfer encoding `${trans_to}'.") 0 36 36
120 or $self->log(WARNING =>
121 "No encoder defined for transfer encoding `$trans_to'.");
122 }
123  
124 47 ▶ my $encoded = defined $trans
Branch: 1 branch
BranchTrueFalseTotal
defined $trans ? : 36 11 47
125 ? $trans->encode($recoded, result_type => $bodytype)
126 : $recoded;
127  
128 47 $encoded;
129 }
130  
131 #------------------------------------------
132  
133  
134 sub check()
135 19 ▶{ my $self = shift;
Subroutine check: called CC=4 SCAR=25.0
Pod documented
136 19 ▶ return $self if $self->checked;
Branch: 1 branch
BranchTrueFalseTotal
if $self->checked 19 0 19
137 0 my $eol = $self->eol;
138  
139 0 my $encoding = $self->transferEncoding->body;
140 0 ▶ return $self->eol($eol)
Branch: 1 branch
BranchTrueFalseTotal
if $encoding eq "none" 0 0 0
141 if $encoding eq 'none';
142  
143 0 my $encoder = $self->getTransferEncHandler($encoding);
144  
145 0 ▶ my $checked
Branch: 1 branch
BranchTrueFalseTotal
$encoder ? : 0 0 0
146 = $encoder
147 ? $encoder->check($self)->eol($eol)
148 : $self->eol($eol);
149  
150 0 $checked->checked(1);
151 0 $checked;
152 }
153  
154 #------------------------------------------
155  
156  
157 sub encoded()
158 53 ▶{ my $self = shift;
Subroutine encoded: called CC=11 SCAR=24.2
Pod documented
159  
160 53 ▶ $mime_types ||= MIME::Types->new;
Condition66%2/3
$mime_types ||= "MIME::Types"->new
l!l&&r!l&&!r
4670
MC/DC0%0/2
$mime_types ||= "MIME::Types"->new
$mime_types "MIME::Types"->new
Truth table66%2/3
A ||= B
A= $mime_typesB= "MIME::Types"->new
ABresult
1X1
011
000
161 53 my $mime = $mime_types->type($self->type->body);
162  
163 53 ▶ my $charset = $self->charset || '';
Condition100%2/2
$self->charset || ''
l!l
494
MC/DC100%1/1
$self->charset || ''
$self->charset
Truth table100%2/2
A
A= $self->charset
Aresult
11
00
164 53 my $enc_was = $self->transferEncoding;
165 53 my $enc = $enc_was;
166 53 ▶ $enc = defined $mime ? $mime->encoding : 'base64'
Branch: 2 branches
BranchTrueFalseTotal
if $enc eq "none" 32 21 53
defined $mime ? : 32 0 32
167 if $enc eq 'none';
168  
169 # we could (expensively) try to autodetect character-set used,
170 # but everything is a subset of utf-8.
171 53 ▶ my $new_charset
Branch: 2 branches
BranchTrueFalseTotal
!($mime && $mime =~ m[^text/]i) ? : 4 49 53
!$charset || $charset eq 'PERL' ? : 28 21 49
Condition66%4/6
$mime && $mime =~ m[^text/]i
!ll&&!rl&&r
0449
not $charset or $charset eq "PERL"
l!l&&r!l&&!r
02821
MC/DC50%1/2
$mime && $mime =~ m[^text/]i
$mime $mime =~ m[^text/]i
MC/DC50%1/2
not $charset or $charset eq "PERL"
not $charset $charset eq "PERL"
Truth table66%2/3
A && B
A= $mimeB= $mime =~ m[^text/]i
ABresult
0X0
100
111
Truth table66%2/3
not(A) or B
A= not $charsetB= $charset eq "PERL"
ABresult
1X1
011
000
172 = (!$mime || $mime !~ m!^text/!i) ? ''
173 : (!$charset || $charset eq 'PERL') ? 'utf-8'
174 : $charset;
175  
176 53 ▶ ($enc_was ne 'none' && $charset eq $new_charset)
Branch: 1 branch
BranchTrueFalseTotal
$enc_was ne 'none' && $charset eq $new_charset ? : 19 34 53
Condition100%3/3
$enc_was ne "none" and $charset eq $new_charset
!ll&&!rl&&r
32219
MC/DC100%2/2
$enc_was ne "none" and $charset eq $new_charset
$enc_was ne "none" $charset eq $new_charset
Truth table100%3/3
A and B
A= $enc_was ne "none"B= $charset eq $new_charset
ABresult
0X0
100
111
177 ? $self->check
178 : $self->encode(transfer_encoding => $enc, charset => $new_charset);
179 }
180  
181 #------------------------------------------
182  
183  
184 sub unify($)
185 0 ▶{ my ($self, $body) = @_;
Subroutine unify: not called CC=4 SCAR=30.0
Pod documented
186 0 ▶ return $self if $self==$body;
Branch: 1 branch
BranchTrueFalseTotal
if $self == $body 0 0 0
187  
188 0 my $mime = $self->type;
189 0 my $transfer = $self->transferEncoding;
190  
191 0 my $encoded = $body->encode
192 ( mime_type => $mime
193 , transfer_encoding => $transfer
194 );
195  
196 # Encode makes the best of it, but is it good enough?
197  
198 0 my $newmime = $encoded->type;
199 0 ▶ return unless $newmime eq $mime;
Branch: 1 branch
BranchTrueFalseTotal
unless $newmime eq $mime 0 0 0
200 0 ▶ return unless $transfer eq $encoded->transferEncoding;
Branch: 1 branch
BranchTrueFalseTotal
unless $transfer eq $encoded->transferEncoding 0 0 0
201 0 $encoded;
202 }
203  
204 #------------------------------------------
205  
206  
207 sub isBinary()
208 11 ▶{ my $self = shift;
Subroutine isBinary: called CC=4 SCAR=14.5
Pod documented
209 11 ▶ $mime_types ||= MIME::Types->new(only_complete => 1);
Condition66%2/3
$mime_types ||= "MIME::Types"->new("only_complete", 1)
l!l&&r!l&&!r
1010
MC/DC0%0/2
$mime_types ||= "MIME::Types"->new("only_complete", 1)
$mime_types "MIME::Types"->new("only_complete", 1)
Truth table66%2/3
A ||= B
A= $mime_typesB= "MIME::Types"->new("only_complete", 1)
ABresult
1X1
011
000
210 11 ▶ my $type = $self->type or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $type = $self->type or return 1 0 11 11
211 11 ▶ my $mime = $mime_types->type($type->body) or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $mime = $mime_types->type($type->body) or return 1 0 11 11
212 11 $mime->isBinary;
213 }
214
215  
216 0 ▶sub isText() { not shift->isBinary }
Subroutine isText: not called CC=1 SCAR=6.9
Pod documented
217  
218  
219 sub dispositionFilename(;$)
220 1 ▶{ my $self = shift;
Subroutine dispositionFilename: called CC=20 SCAR=42.8
Pod documented
221 1 my $raw;
222  
223 my $field;
224 1 ▶ if($field = $self->disposition)
Branch: 1 branch
BranchTrueFalseTotal
if ($field = $self->disposition) 1 0 1
225 1 ▶ { $field = $field->study if $field->can('study');
Branch: 1 branch
BranchTrueFalseTotal
if $field->can("study") 1 0 1
226 1 ▶ $raw = $field->attribute('filename')
Condition33%2/6
$field->attribute('filename') || $field->attribute('file') || $field->attribute('name')
l!l&&r!l&&!r
001
$field->attribute("filename") or $field->attribute("file")
l!l&&r!l&&!r
001
MC/DC0%0/3
$field->attribute('filename') || $field->attribute('file') || $field->attribute('name')
$field->attribute("filename") $field->attribute("file") $field->attribute('name')
Truth table25%1/4
A or B || C
A= $field->attribute("filename")B= $field->attribute("file")C= $field->attribute('name')
ABCresult
1XX1
01X1
0011
0000
227 || $field->attribute('file')
228 || $field->attribute('name');
229 }
230  
231 1 ▶ if(!defined $raw && ($field = $self->type))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $raw and $field = $self->type) 1 0 1
Condition33%1/3
not defined $raw and $field = $self->type
!ll&&!rl&&r
001
MC/DC0%0/2
not defined $raw and $field = $self->type
not defined $raw $field = $self->type
Truth table33%1/3
not(A) and B
A= not defined $rawB= $field = $self->type
ABresult
0X0
100
111
232 1 ▶ { $field = $field->study if $field->can('study');
Branch: 1 branch
BranchTrueFalseTotal
if $field->can("study") 1 0 1
233 1 ▶ $raw = $field->attribute('filename')
Condition33%2/6
$field->attribute('filename') || $field->attribute('file') || $field->attribute('name')
l!l&&r!l&&!r
001
$field->attribute("filename") or $field->attribute("file")
l!l&&r!l&&!r
001
MC/DC0%0/3
$field->attribute('filename') || $field->attribute('file') || $field->attribute('name')
$field->attribute("filename") $field->attribute("file") $field->attribute('name')
Truth table25%1/4
A or B || C
A= $field->attribute("filename")B= $field->attribute("file")C= $field->attribute('name')
ABCresult
1XX1
01X1
0011
0000
234 || $field->attribute('file')
235 || $field->attribute('name');
236 }
237  
238 1 my $base;
239 1 ▶ if(!defined $raw || !length $raw) {}
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $raw && length $raw) { } 1 0 1
elsif (index($raw, '?') != -1) { } 0 0 0
Condition33%1/3
defined $raw && length $raw
!ll&&!rl&&r
100
MC/DC0%0/2
defined $raw && length $raw
defined $raw length $raw
Truth table33%1/3
A && B
A= defined $rawB= length $raw
ABresult
0X0
100
111
240 elsif(index($raw, '?') >= 0)
241 0 { eval 'require Mail::Message::Field::Full';
242 0 $base = Mail::Message::Field::Full->decode($raw);
243 }
244 else
245 0 { $base = $raw;
246 }
247  
248 1 ▶ return $base
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 1 1
249 unless @_;
250  
251 1 my $dir = shift;
252 1 my $filename = '';
253 1 ▶ if(defined $base) # RFC6266 section 4.3, very safe
Branch: 1 branch
BranchTrueFalseTotal
if (defined $base) 0 1 1
254 0 { $filename = basename $base;
255 0 for($filename)
256 0 { s/\s+/ /g; s/ $//; s/^ //;
257 0 s/[^\w .-]//g;
258 }
259 }
260  
261 1 ▶ my ($filebase, $ext) = length $filename && $filename =~ m/(.*)\.([^.]+)/
Branch: 1 branch
BranchTrueFalseTotal
length $filename && $filename =~ /(.*)\.([^.]+)/ ? : 0 1 1
Condition40%2/5
length $filename and $filename =~ /(.*)\.([^.]+)/
!ll&&!rl&&r
100
($self->mimeType->extensions)[0] or "raw"
l!l
10
MC/DC0%0/2
length $filename and $filename =~ /(.*)\.([^.]+)/
length $filename $filename =~ /(.*)\.([^.]+)/
MC/DC0%0/1
($self->mimeType->extensions)[0] or "raw"
($self->mimeType->extensions)[0]
Truth table33%1/3
A and B
A= length $filenameB= $filename =~ /(.*)\.([^.]+)/
ABresult
0X0
100
111
Truth table50%1/2
A
A= ($self->mimeType->extensions)[0]
Aresult
11
00
262 ? ($1, $2) : (part => ($self->mimeType->extensions)[0] || 'raw');
263  
264 1 my $fn = File::Spec->catfile($dir, "$filebase.$ext");
265  
266 1 ▶ for(my $unique = 1; -e $fn; $unique++)
Branch: 1 branch
BranchTrueFalseTotal
if (-e $fn) 0 1 1
267 0 { $fn = File::Spec->catfile($dir, "$filebase-$unique.$ext");
268 }
269  
270 1 $fn;
271 }
272  
273 #------------------------------------------
274  
275  
276 12 my %transfer_encoder_classes =
277 ( base64 => 'Mail::Message::TransferEnc::Base64'
278 , binary => 'Mail::Message::TransferEnc::Binary'
279 , '8bit' => 'Mail::Message::TransferEnc::EightBit'
280 , 'quoted-printable' => 'Mail::Message::TransferEnc::QuotedPrint'
281 , '7bit' => 'Mail::Message::TransferEnc::SevenBit'
282 );
283  
284 12 my %transfer_encoders; # they are reused.
285  
286 sub getTransferEncHandler($)
287 45 ▶{ my ($self, $type) = @_;
Subroutine getTransferEncHandler: called CC=4 SCAR=14.0
Pod documented
288  
289 return $transfer_encoders{$type}
290 45 ▶ if exists $transfer_encoders{$type}; # they are reused.
Branch: 1 branch
BranchTrueFalseTotal
if exists $transfer_encoders{$type} 34 11 45
291  
292 11 my $class = $transfer_encoder_classes{$type};
293 11 ▶ return unless $class;
Branch: 1 branch
BranchTrueFalseTotal
unless $class 0 11 11
294  
295 11 eval "require $class";
296 11 ▶ confess "Cannot load $class: $@\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 11 11
297  
298 11 $transfer_encoders{$type} = $class->new;
299 }
300  
301  
302 sub addTransferEncHandler($$)
303 0 ▶{ my ($this, $name, $what) = @_;
Subroutine addTransferEncHandler: not called CC=2 SCAR=17.9
Pod documented
304  
305 0 my $class;
306 0 ▶ if(ref $what)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $what) { } 0 0 0
307 0 { $transfer_encoders{$name} = $what;
308 0 $class = ref $what;
309 }
310 else
311 0 { delete $transfer_encoders{$name};
312 0 $class = $what;
313 }
314  
315 0 $transfer_encoder_classes{$name} = $class;
316 0 $this;
317 }
318  
319 12 1;
« Message/Replace/MailInternet.pm ↑ Summary Message/Head/SpamGroup.pm »