line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2021 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.02. |
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::Head; |
10
|
35
|
|
|
35
|
|
292
|
use vars '$VERSION'; |
|
35
|
|
|
|
|
72
|
|
|
35
|
|
|
|
|
1774
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.011'; |
12
|
|
|
|
|
|
|
|
13
|
35
|
|
|
35
|
|
201
|
use base 'Mail::Reporter'; |
|
35
|
|
|
|
|
75
|
|
|
35
|
|
|
|
|
5332
|
|
14
|
|
|
|
|
|
|
|
15
|
35
|
|
|
35
|
|
247
|
use strict; |
|
35
|
|
|
|
|
82
|
|
|
35
|
|
|
|
|
955
|
|
16
|
35
|
|
|
35
|
|
192
|
use warnings; |
|
35
|
|
|
|
|
62
|
|
|
35
|
|
|
|
|
1193
|
|
17
|
|
|
|
|
|
|
|
18
|
35
|
|
|
35
|
|
223
|
use Mail::Message::Head::Complete; |
|
35
|
|
|
|
|
72
|
|
|
35
|
|
|
|
|
1090
|
|
19
|
35
|
|
|
35
|
|
16114
|
use Mail::Message::Field::Fast; |
|
35
|
|
|
|
|
123
|
|
|
35
|
|
|
|
|
1200
|
|
20
|
|
|
|
|
|
|
|
21
|
35
|
|
|
35
|
|
238
|
use Carp; |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
2283
|
|
22
|
35
|
|
|
35
|
|
206
|
use Scalar::Util 'weaken'; |
|
35
|
|
|
|
|
74
|
|
|
35
|
|
|
|
|
1939
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
35
|
|
|
|
|
246
|
use overload qq("") => 'string_unless_carp' |
26
|
35
|
|
|
35
|
|
241
|
, bool => 'isEmpty'; |
|
35
|
|
|
|
|
93
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# To satisfy overload in static resolving. |
29
|
0
|
|
|
0
|
0
|
0
|
sub toString() { shift->load->toString } |
30
|
0
|
|
|
0
|
0
|
0
|
sub string() { shift->load->string } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub string_unless_carp() |
33
|
0
|
|
|
0
|
0
|
0
|
{ my $self = shift; |
34
|
0
|
0
|
|
|
|
0
|
return $self->toString unless (caller)[0] eq 'Carp'; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
(my $class = ref $self) =~ s/^Mail::Message/MM/; |
37
|
0
|
|
|
|
|
0
|
"$class object"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#------------------------------------------ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new(@) |
44
|
140
|
|
|
140
|
1
|
1212
|
{ my $class = shift; |
45
|
|
|
|
|
|
|
|
46
|
140
|
50
|
|
|
|
375
|
return Mail::Message::Head::Complete->new(@_) |
47
|
|
|
|
|
|
|
if $class eq __PACKAGE__; |
48
|
|
|
|
|
|
|
|
49
|
140
|
|
|
|
|
567
|
$class->SUPER::new(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub init($) |
53
|
140
|
|
|
140
|
0
|
318
|
{ my ($self, $args) = @_; |
54
|
|
|
|
|
|
|
|
55
|
140
|
|
|
|
|
454
|
$self->SUPER::init($args); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{MMH_field_type} = $args->{field_type} |
58
|
140
|
50
|
|
|
|
358
|
if $args->{field_type}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->message($args->{message}) |
61
|
140
|
100
|
|
|
|
358
|
if defined $args->{message}; |
62
|
|
|
|
|
|
|
|
63
|
140
|
|
|
|
|
320
|
$self->{MMH_fields} = {}; |
64
|
140
|
|
|
|
|
332
|
$self->{MMH_order} = []; |
65
|
140
|
|
50
|
|
|
562
|
$self->{MMH_modified} = $args->{modified} || 0; |
66
|
140
|
|
|
|
|
663
|
$self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub build(@) |
71
|
3
|
|
|
3
|
1
|
312
|
{ shift; |
72
|
3
|
|
|
|
|
33
|
Mail::Message::Head::Complete->build(@_); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#------------------------------------------ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
1
|
0
|
sub isDelayed { 1 } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub modified(;$) |
82
|
62
|
|
|
62
|
1
|
106
|
{ my $self = shift; |
83
|
62
|
50
|
|
|
|
148
|
return $self->isModified unless @_; |
84
|
62
|
|
|
|
|
139
|
$self->{MMH_modified} = shift; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
1
|
0
|
sub isModified() { shift->{MMH_modified} } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
154
|
|
|
154
|
1
|
323
|
sub isEmpty { scalar keys %{shift->{MMH_fields}} } |
|
154
|
|
|
|
|
593
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub message(;$) |
95
|
123
|
|
|
123
|
1
|
216
|
{ my $self = shift; |
96
|
123
|
50
|
|
|
|
318
|
if(@_) |
97
|
123
|
|
|
|
|
278
|
{ $self->{MMH_message} = shift; |
98
|
123
|
|
|
|
|
444
|
weaken($self->{MMH_message}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
123
|
|
|
|
|
278
|
$self->{MMH_message}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
197
|
|
|
197
|
1
|
299
|
sub orderedFields() { grep defined $_, @{shift->{MMH_order}} } |
|
197
|
|
|
|
|
1181
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
10
|
|
|
10
|
1
|
16
|
sub knownNames() { keys %{shift->{MMH_fields}} } |
|
10
|
|
|
|
|
70
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#------------------------------------------ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get($;$) |
114
|
737
|
|
|
737
|
1
|
8036
|
{ my $known = shift->{MMH_fields}; |
115
|
737
|
|
|
|
|
1414
|
my $value = $known->{lc(shift)}; |
116
|
737
|
|
|
|
|
995
|
my $index = shift; |
117
|
|
|
|
|
|
|
|
118
|
737
|
100
|
|
|
|
1651
|
if(defined $index) |
|
|
100
|
|
|
|
|
|
119
|
160
|
50
|
|
|
|
608
|
{ return ! defined $value ? undef |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
120
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? $value->[$index] |
121
|
|
|
|
|
|
|
: $index == 0 ? $value |
122
|
|
|
|
|
|
|
: undef; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
elsif(wantarray) |
125
|
22
|
100
|
|
|
|
182
|
{ return ! defined $value ? () |
|
|
100
|
|
|
|
|
|
126
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? @$value |
127
|
|
|
|
|
|
|
: ($value); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else |
130
|
555
|
100
|
|
|
|
2717
|
{ return ! defined $value ? undef |
|
|
100
|
|
|
|
|
|
131
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? $value->[-1] |
132
|
|
|
|
|
|
|
: $value; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
0
|
0
|
0
|
sub get_all(@) { my @all = shift->get(@_) } # compatibility, force list |
137
|
0
|
|
|
0
|
0
|
0
|
sub setField($$) {shift->add(@_)} # compatibility |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub study($;$) |
141
|
2
|
|
|
2
|
1
|
16
|
{ my $self = shift; |
142
|
2
|
100
|
|
|
|
11
|
return map {$_->study} $self->get(@_) |
|
3
|
|
|
|
|
15
|
|
143
|
|
|
|
|
|
|
if wantarray; |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
|
|
7
|
my $got = $self->get(@_); |
146
|
1
|
50
|
|
|
|
9
|
defined $got ? $got->study : undef; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#------------------------------------------ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub isMultipart() |
154
|
130
|
|
|
130
|
1
|
298
|
{ my $type = shift->get('Content-Type', 0); |
155
|
130
|
50
|
|
|
|
373
|
$type && scalar $type->body =~ m[^multipart/]i; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#------------------------------ |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub read($) |
161
|
12
|
|
|
12
|
1
|
29
|
{ my ($self, $parser) = @_; |
162
|
|
|
|
|
|
|
|
163
|
12
|
|
|
|
|
39
|
my @fields = $parser->readHeader; |
164
|
12
|
|
|
|
|
49
|
@$self{ qw/MMH_begin MMH_end/ } = (shift @fields, shift @fields); |
165
|
|
|
|
|
|
|
|
166
|
12
|
|
50
|
|
|
54
|
my $type = $self->{MMH_field_type} || 'Mail::Message::Field::Fast'; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self->addNoRealize($type->new( @$_ )) |
169
|
12
|
|
|
|
|
88
|
for @fields; |
170
|
|
|
|
|
|
|
|
171
|
12
|
|
|
|
|
62
|
$self; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Warning: fields are added in addResentGroup() as well! |
176
|
|
|
|
|
|
|
sub addOrderedFields(@) |
177
|
573
|
|
|
573
|
1
|
951
|
{ my $order = shift->{MMH_order}; |
178
|
573
|
|
|
|
|
1039
|
foreach (@_) |
179
|
574
|
|
|
|
|
1066
|
{ push @$order, $_; |
180
|
574
|
|
|
|
|
1619
|
weaken( $order->[-1] ); |
181
|
|
|
|
|
|
|
} |
182
|
573
|
|
|
|
|
1006
|
@_; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
0
|
1
|
0
|
sub load($) {shift} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub fileLocation() |
190
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
191
|
0
|
|
|
|
|
0
|
@$self{ qw/MMH_begin MMH_end/ }; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub moveLocation($) |
196
|
0
|
|
|
0
|
1
|
0
|
{ my ($self, $dist) = @_; |
197
|
0
|
|
|
|
|
0
|
$self->{MMH_begin} -= $dist; |
198
|
0
|
|
|
|
|
0
|
$self->{MMH_end} -= $dist; |
199
|
0
|
|
|
|
|
0
|
$self; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub setNoRealize($) |
204
|
0
|
|
|
0
|
1
|
0
|
{ my ($self, $field) = @_; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
0
|
my $known = $self->{MMH_fields}; |
207
|
0
|
|
|
|
|
0
|
my $name = $field->name; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
0
|
$self->addOrderedFields($field); |
210
|
0
|
|
|
|
|
0
|
$known->{$name} = $field; |
211
|
0
|
|
|
|
|
0
|
$field; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub addNoRealize($) |
216
|
231
|
|
|
231
|
1
|
412
|
{ my ($self, $field) = @_; |
217
|
|
|
|
|
|
|
|
218
|
231
|
|
|
|
|
351
|
my $known = $self->{MMH_fields}; |
219
|
231
|
|
|
|
|
461
|
my $name = $field->name; |
220
|
|
|
|
|
|
|
|
221
|
231
|
|
|
|
|
594
|
$self->addOrderedFields($field); |
222
|
|
|
|
|
|
|
|
223
|
231
|
100
|
|
|
|
436
|
if(defined $known->{$name}) |
224
|
4
|
100
|
|
|
|
15
|
{ if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
225
|
3
|
|
|
|
|
10
|
else { $known->{$name} = [ $known->{$name}, $field ] } |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
else |
228
|
227
|
|
|
|
|
441
|
{ $known->{$name} = $field; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
231
|
|
|
|
|
604
|
$field; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
#------------------------------------------ |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |