line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2023 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
|
34
|
|
|
34
|
|
255
|
use vars '$VERSION'; |
|
34
|
|
|
|
|
86
|
|
|
34
|
|
|
|
|
1903
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.013'; |
12
|
|
|
|
|
|
|
|
13
|
34
|
|
|
34
|
|
215
|
use base 'Mail::Message::Body'; |
|
34
|
|
|
|
|
99
|
|
|
34
|
|
|
|
|
3366
|
|
14
|
|
|
|
|
|
|
|
15
|
34
|
|
|
34
|
|
238
|
use strict; |
|
34
|
|
|
|
|
86
|
|
|
34
|
|
|
|
|
913
|
|
16
|
34
|
|
|
34
|
|
188
|
use warnings; |
|
34
|
|
|
|
|
81
|
|
|
34
|
|
|
|
|
1134
|
|
17
|
|
|
|
|
|
|
|
18
|
34
|
|
|
34
|
|
220
|
use Mail::Message::Body::Lines; |
|
34
|
|
|
|
|
100
|
|
|
34
|
|
|
|
|
1285
|
|
19
|
34
|
|
|
34
|
|
223
|
use Mail::Message::Part; |
|
34
|
|
|
|
|
97
|
|
|
34
|
|
|
|
|
1034
|
|
20
|
|
|
|
|
|
|
|
21
|
34
|
|
|
34
|
|
223
|
use Carp; |
|
34
|
|
|
|
|
89
|
|
|
34
|
|
|
|
|
37003
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub init($) |
25
|
13
|
|
|
13
|
0
|
36
|
{ my ($self, $args) = @_; |
26
|
13
|
|
50
|
|
|
82
|
$args->{mime_type} ||= 'message/rfc822'; |
27
|
|
|
|
|
|
|
|
28
|
13
|
|
|
|
|
57
|
$self->SUPER::init($args); |
29
|
|
|
|
|
|
|
|
30
|
13
|
|
|
|
|
31
|
my $nested; |
31
|
13
|
100
|
|
|
|
56
|
if(my $raw = $args->{nested}) |
32
|
12
|
|
|
|
|
199
|
{ $nested = Mail::Message::Part->coerce($raw, $self); |
33
|
|
|
|
|
|
|
|
34
|
12
|
50
|
|
|
|
42
|
croak 'Data not convertible to a message (type is ', ref $raw,")\n" |
35
|
|
|
|
|
|
|
unless defined $nested; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
13
|
|
|
|
|
54
|
$self->{MMBN_nested} = $nested; |
39
|
13
|
|
|
|
|
63
|
$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
|
|
|
|
|
7
|
ref($self)->new |
50
|
|
|
|
|
|
|
( $self->logSettings |
51
|
|
|
|
|
|
|
, based_on => $self |
52
|
|
|
|
|
|
|
, nested => $self->nested->clone |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
11
|
|
|
11
|
1
|
44
|
sub nrLines() { shift->nested->nrLines } |
57
|
|
|
|
|
|
|
|
58
|
13
|
|
|
13
|
1
|
43
|
sub size() { shift->nested->size } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub string() |
61
|
1
|
|
|
1
|
1
|
4
|
{ my $nested = shift->nested; |
62
|
1
|
50
|
|
|
|
17
|
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
|
9
|
{ my $self = shift; |
77
|
3
|
|
33
|
|
|
11
|
$self->nested->print(shift || select); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub partNumberOf($) |
81
|
3
|
|
|
3
|
1
|
11
|
{ my ($self, $part) = @_; |
82
|
3
|
100
|
|
|
|
12
|
$self->message->partNumber || '1'; |
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
|
5
|
{ my ($self, %args) = @_; |
96
|
1
|
|
|
1
|
|
8
|
$self->forNested( sub {$_[1]->encode(%args)} ); |
|
1
|
|
|
|
|
10
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
7
|
|
|
7
|
1
|
32
|
sub encoded() { shift->forNested( sub {$_[1]->encoded} ) } |
|
7
|
|
|
7
|
|
46
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub read($$$$) |
102
|
1
|
|
|
1
|
1
|
6
|
{ my ($self, $parser, $head, $bodytype) = @_; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
9
|
my $nest = Mail::Message::Part->new(container => undef); |
105
|
1
|
50
|
|
|
|
22
|
$nest->readFromParser($parser, $bodytype) |
106
|
|
|
|
|
|
|
or return; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
9
|
$nest->container($self); |
109
|
1
|
|
|
|
|
3
|
$self->{MMBN_nested} = $nest; |
110
|
1
|
|
|
|
|
4
|
$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
|
7
|
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
|
|
|
|
|
|
|
|
135
|
63
|
|
|
63
|
1
|
322
|
sub nested() { shift->{MMBN_nested} } |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub forNested($) |
139
|
8
|
|
|
8
|
1
|
24
|
{ my ($self, $code) = @_; |
140
|
8
|
|
|
|
|
35
|
my $nested = $self->nested; |
141
|
8
|
|
|
|
|
27
|
my $body = $nested->body; |
142
|
|
|
|
|
|
|
|
143
|
8
|
50
|
|
|
|
34
|
my $new_body = $code->($self, $body) |
144
|
|
|
|
|
|
|
or return; |
145
|
|
|
|
|
|
|
|
146
|
8
|
100
|
|
|
|
31
|
return $self if $new_body == $body; |
147
|
|
|
|
|
|
|
|
148
|
4
|
|
|
|
|
33
|
my $new_nested = Mail::Message::Part->new |
149
|
|
|
|
|
|
|
( head => $nested->head->clone |
150
|
|
|
|
|
|
|
, container => undef |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
4
|
|
|
|
|
24
|
$new_nested->body($new_body); |
154
|
|
|
|
|
|
|
|
155
|
4
|
|
|
|
|
41
|
my $created = (ref $self)->new |
156
|
|
|
|
|
|
|
( based_on => $self |
157
|
|
|
|
|
|
|
, nested => $new_nested |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
4
|
|
|
|
|
20
|
$new_nested->container($created); |
161
|
4
|
|
|
|
|
24
|
$created; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
0
|
|
0
|
0
|
|
sub toplevel() { my $msg = shift->message; $msg ? $msg->toplevel : undef} |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |