| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution Mail-Message version 4.04. |
|
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;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.04'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
8
|
|
|
8
|
|
1869
|
use strict; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
343
|
|
|
18
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
646
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
8
|
|
|
8
|
|
64
|
use Log::Report 'mail-message', import => [ qw/__x error warning/ ]; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
81
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
5959
|
use Mail::Box::Parser::Lines (); |
|
|
8
|
|
|
|
|
24
|
|
|
|
8
|
|
|
|
|
301
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
8
|
|
55
|
use Scalar::Util qw/blessed/; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
4801
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#-------------------- |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _scalar2lines($) |
|
29
|
15
|
|
|
15
|
|
30
|
{ my $lines = [ split /^/, ${$_[0]} ]; |
|
|
15
|
|
|
|
|
145
|
|
|
30
|
|
|
|
|
|
|
# pop @$lines if @$lines && ! length $lines->[-1]; |
|
31
|
15
|
|
|
|
|
63
|
$lines; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub read($@) |
|
35
|
|
|
|
|
|
|
{ # try avoiding copy of large strings |
|
36
|
16
|
|
|
16
|
1
|
4551
|
my ($class, undef, %args) = @_; |
|
37
|
16
|
50
|
|
|
|
116
|
my $trusted = exists $args{trusted} ? $args{trusted} : 1; |
|
38
|
16
|
100
|
|
|
|
54
|
my $strip_status = exists $args{strip_status_fields} ? delete $args{strip_status_fields} : 1; |
|
39
|
16
|
|
|
|
|
35
|
my $body_type = $args{body_type}; |
|
40
|
16
|
|
|
|
|
33
|
my $pclass = $args{parser_class}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
16
|
|
|
|
|
28
|
my $parser; |
|
43
|
16
|
|
|
|
|
42
|
my $ref = ref $_[1]; |
|
44
|
|
|
|
|
|
|
|
|
45
|
16
|
50
|
|
|
|
46
|
if($args{seekable}) |
|
46
|
0
|
|
0
|
|
|
0
|
{ $parser = ($pclass // 'Mail::Box::Parser::Perl') |
|
47
|
|
|
|
|
|
|
->new(%args, filename => "file ($ref)", file => $_[1], trusted => $trusted); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
else |
|
50
|
16
|
|
|
|
|
35
|
{ my ($source, $lines); |
|
51
|
16
|
100
|
33
|
|
|
94
|
if(!$ref) |
|
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
52
|
12
|
|
|
|
|
22
|
{ $source = 'scalar'; |
|
53
|
12
|
|
|
|
|
42
|
$lines = _scalar2lines \$_[1]; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
elsif($ref eq 'SCALAR') |
|
56
|
1
|
|
|
|
|
3
|
{ $source = 'ref scalar'; |
|
57
|
1
|
|
|
|
|
5
|
$lines = _scalar2lines $_[1]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
elsif($ref eq 'ARRAY') |
|
60
|
1
|
|
|
|
|
3
|
{ $source = 'array of lines'; |
|
61
|
1
|
|
|
|
|
4
|
$lines = $_[1]; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
elsif($ref eq 'GLOB' || (blessed $_[1] && $_[1]->isa('IO::Handle'))) |
|
64
|
2
|
|
|
|
|
5
|
{ $source = "file ($ref)"; |
|
65
|
2
|
|
|
|
|
14
|
local $/ = undef; # slurp |
|
66
|
2
|
|
|
|
|
119
|
$lines = _scalar2lines \$_[1]->getline; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else |
|
69
|
0
|
|
|
|
|
0
|
{ error __x"cannot read message from a {source}.", source => $_[1]/$ref; |
|
70
|
0
|
|
|
|
|
0
|
return undef; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
16
|
|
50
|
|
|
228
|
$parser = ($pclass // 'Mail::Box::Parser::Lines') |
|
74
|
|
|
|
|
|
|
->new(%args, source => $source, lines => $lines, trusted => $trusted); |
|
75
|
|
|
|
|
|
|
|
|
76
|
16
|
|
|
|
|
40
|
$body_type = 'Mail::Message::Body::Lines'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
16
|
|
|
|
|
74
|
my $self = $class->new(%args); |
|
80
|
16
|
|
|
|
|
92
|
$self->readFromParser($parser, $body_type); |
|
81
|
16
|
|
|
|
|
105
|
$parser->stop; |
|
82
|
|
|
|
|
|
|
|
|
83
|
16
|
|
|
|
|
40
|
my $head = $self->head; |
|
84
|
16
|
100
|
|
|
|
56
|
$head->set('Message-ID' => '<'.$self->messageId.'>') unless $head->get('Message-ID'); |
|
85
|
|
|
|
|
|
|
|
|
86
|
16
|
100
|
|
|
|
83
|
$head->delete('Status', 'X-Status') |
|
87
|
|
|
|
|
|
|
if $strip_status; |
|
88
|
|
|
|
|
|
|
|
|
89
|
16
|
|
|
|
|
87
|
$self; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |