line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2022 by [Mark Overmeer ]. |
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::Nested; |
10
|
31
|
|
|
31
|
|
215
|
use vars '$VERSION'; |
|
31
|
|
|
|
|
66
|
|
|
31
|
|
|
|
|
1716
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.012'; |
12
|
|
|
|
|
|
|
|
13
|
31
|
|
|
31
|
|
173
|
use base 'Mail::Message::Body'; |
|
31
|
|
|
|
|
69
|
|
|
31
|
|
|
|
|
3416
|
|
14
|
|
|
|
|
|
|
|
15
|
31
|
|
|
31
|
|
196
|
use strict; |
|
31
|
|
|
|
|
57
|
|
|
31
|
|
|
|
|
746
|
|
16
|
31
|
|
|
31
|
|
150
|
use warnings; |
|
31
|
|
|
|
|
90
|
|
|
31
|
|
|
|
|
1037
|
|
17
|
|
|
|
|
|
|
|
18
|
31
|
|
|
31
|
|
188
|
use Mail::Message::Body::Lines; |
|
31
|
|
|
|
|
65
|
|
|
31
|
|
|
|
|
1059
|
|
19
|
31
|
|
|
31
|
|
170
|
use Mail::Message::Part; |
|
31
|
|
|
|
|
94
|
|
|
31
|
|
|
|
|
777
|
|
20
|
|
|
|
|
|
|
|
21
|
31
|
|
|
31
|
|
157
|
use Carp; |
|
31
|
|
|
|
|
63
|
|
|
31
|
|
|
|
|
28295
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub init($) |
25
|
11
|
|
|
11
|
0
|
39
|
{ my ($self, $args) = @_; |
26
|
11
|
|
50
|
|
|
70
|
$args->{mime_type} ||= 'message/rfc822'; |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
51
|
$self->SUPER::init($args); |
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
|
|
17
|
my $nested; |
31
|
11
|
100
|
|
|
|
48
|
if(my $raw = $args->{nested}) |
32
|
10
|
|
|
|
|
52
|
{ $nested = Mail::Message::Part->coerce($raw, $self); |
33
|
|
|
|
|
|
|
|
34
|
10
|
50
|
|
|
|
32
|
croak 'Data not convertible to a message (type is ', ref $raw,")\n" |
35
|
|
|
|
|
|
|
unless defined $nested; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
11
|
|
|
|
|
29
|
$self->{MMBN_nested} = $nested; |
39
|
11
|
|
|
|
|
43
|
$self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub isNested() {1} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
0
|
sub isBinary() { shift->nested->body->isBinary } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub clone() |
47
|
1
|
|
|
1
|
1
|
3
|
{ my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
5
|
ref($self)->new |
50
|
|
|
|
|
|
|
( $self->logSettings |
51
|
|
|
|
|
|
|
, based_on => $self |
52
|
|
|
|
|
|
|
, nested => $self->nested->clone |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
10
|
|
|
10
|
1
|
31
|
sub nrLines() { shift->nested->nrLines } |
57
|
|
|
|
|
|
|
|
58
|
12
|
|
|
12
|
1
|
185
|
sub size() { shift->nested->size } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub string() |
61
|
1
|
|
|
1
|
1
|
6
|
{ my $nested = shift->nested; |
62
|
1
|
50
|
|
|
|
23
|
defined $nested ? $nested->string : ''; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub lines() |
66
|
0
|
|
|
0
|
1
|
0
|
{ my $nested = shift->nested; |
67
|
0
|
0
|
|
|
|
0
|
defined $nested ? ($nested->lines) : (); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub file() |
71
|
0
|
|
|
0
|
1
|
0
|
{ my $nested = shift->nested; |
72
|
0
|
0
|
|
|
|
0
|
defined $nested ? $nested->file : undef; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub print(;$) |
76
|
3
|
|
|
3
|
1
|
8
|
{ my $self = shift; |
77
|
3
|
|
33
|
|
|
9
|
$self->nested->print(shift || select); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub partNumberOf($) |
81
|
1
|
|
|
1
|
1
|
3
|
{ my ($self, $part) = @_; |
82
|
1
|
|
|
|
|
4
|
$self->message->partNumber; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub foreachLine($) |
87
|
0
|
|
|
0
|
1
|
0
|
{ my ($self, $code) = @_; |
88
|
0
|
|
|
|
|
0
|
$self->log(ERROR => "You cannot use foreachLine on a nested"); |
89
|
0
|
|
|
|
|
0
|
confess; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
1
|
0
|
sub check() { shift->forNested( sub {$_[1]->check} ) } |
|
0
|
|
|
0
|
|
0
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub encode(@) |
95
|
1
|
|
|
1
|
1
|
7
|
{ my ($self, %args) = @_; |
96
|
1
|
|
|
1
|
|
10
|
$self->forNested( sub {$_[1]->encode(%args)} ); |
|
1
|
|
|
|
|
11
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
6
|
|
|
6
|
1
|
35
|
sub encoded() { shift->forNested( sub {$_[1]->encoded} ) } |
|
6
|
|
|
6
|
|
52
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub read($$$$) |
102
|
1
|
|
|
1
|
1
|
4
|
{ my ($self, $parser, $head, $bodytype) = @_; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
4
|
my $nest = Mail::Message::Part->new(container => undef); |
105
|
1
|
50
|
|
|
|
11
|
$nest->readFromParser($parser, $bodytype) |
106
|
|
|
|
|
|
|
or return; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
5
|
$nest->container($self); |
109
|
1
|
|
|
|
|
3
|
$self->{MMBN_nested} = $nest; |
110
|
1
|
|
|
|
|
3
|
$self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub fileLocation() |
114
|
0
|
|
|
0
|
1
|
0
|
{ my $nested = shift->nested; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
( ($nested->head->fileLocation)[0] |
117
|
|
|
|
|
|
|
, ($nested->body->fileLocation)[1] |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
2
|
|
|
2
|
1
|
6
|
sub endsOnNewline() { shift->nested->body->endsOnNewline } |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub moveLocation($) |
124
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
125
|
0
|
|
|
|
|
0
|
my $nested = $self->nested; |
126
|
0
|
0
|
|
|
|
0
|
my $dist = shift or return $self; # no move |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
$nested->head->moveLocation($dist); |
129
|
0
|
|
|
|
|
0
|
$nested->body->moveLocation($dist); |
130
|
0
|
|
|
|
|
0
|
$self; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
58
|
|
|
58
|
1
|
271
|
sub nested() { shift->{MMBN_nested} } |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub forNested($) |
138
|
7
|
|
|
7
|
1
|
24
|
{ my ($self, $code) = @_; |
139
|
7
|
|
|
|
|
26
|
my $nested = $self->nested; |
140
|
7
|
|
|
|
|
164
|
my $body = $nested->body; |
141
|
|
|
|
|
|
|
|
142
|
7
|
50
|
|
|
|
25
|
my $new_body = $code->($self, $body) |
143
|
|
|
|
|
|
|
or return; |
144
|
|
|
|
|
|
|
|
145
|
7
|
100
|
|
|
|
25
|
return $self if $new_body == $body; |
146
|
|
|
|
|
|
|
|
147
|
3
|
|
|
|
|
23
|
my $new_nested = Mail::Message::Part->new |
148
|
|
|
|
|
|
|
( head => $nested->head->clone |
149
|
|
|
|
|
|
|
, container => undef |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
|
152
|
3
|
|
|
|
|
17
|
$new_nested->body($new_body); |
153
|
|
|
|
|
|
|
|
154
|
3
|
|
|
|
|
22
|
my $created = (ref $self)->new |
155
|
|
|
|
|
|
|
( based_on => $self |
156
|
|
|
|
|
|
|
, nested => $new_nested |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
|
159
|
3
|
|
|
|
|
15
|
$new_nested->container($created); |
160
|
3
|
|
|
|
|
31
|
$created; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
0
|
0
|
|
sub toplevel() { my $msg = shift->message; $msg ? $msg->toplevel : undef} |
|
0
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |