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::Head; |
10
|
35
|
|
|
35
|
|
255
|
use vars '$VERSION'; |
|
35
|
|
|
|
|
63
|
|
|
35
|
|
|
|
|
1461
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.012'; |
12
|
|
|
|
|
|
|
|
13
|
35
|
|
|
35
|
|
171
|
use base 'Mail::Reporter'; |
|
35
|
|
|
|
|
59
|
|
|
35
|
|
|
|
|
4559
|
|
14
|
|
|
|
|
|
|
|
15
|
35
|
|
|
35
|
|
223
|
use strict; |
|
35
|
|
|
|
|
56
|
|
|
35
|
|
|
|
|
791
|
|
16
|
35
|
|
|
35
|
|
168
|
use warnings; |
|
35
|
|
|
|
|
87
|
|
|
35
|
|
|
|
|
1054
|
|
17
|
|
|
|
|
|
|
|
18
|
35
|
|
|
35
|
|
177
|
use Mail::Message::Head::Complete; |
|
35
|
|
|
|
|
65
|
|
|
35
|
|
|
|
|
866
|
|
19
|
35
|
|
|
35
|
|
13204
|
use Mail::Message::Field::Fast; |
|
35
|
|
|
|
|
118
|
|
|
35
|
|
|
|
|
960
|
|
20
|
|
|
|
|
|
|
|
21
|
35
|
|
|
35
|
|
191
|
use Carp; |
|
35
|
|
|
|
|
69
|
|
|
35
|
|
|
|
|
2032
|
|
22
|
35
|
|
|
35
|
|
184
|
use Scalar::Util 'weaken'; |
|
35
|
|
|
|
|
66
|
|
|
35
|
|
|
|
|
1603
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
35
|
|
|
|
|
197
|
use overload qq("") => 'string_unless_carp' |
26
|
35
|
|
|
35
|
|
192
|
, bool => 'isEmpty'; |
|
35
|
|
|
|
|
81
|
|
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
|
1140
|
{ my $class = shift; |
45
|
|
|
|
|
|
|
|
46
|
140
|
50
|
|
|
|
379
|
return Mail::Message::Head::Complete->new(@_) |
47
|
|
|
|
|
|
|
if $class eq __PACKAGE__; |
48
|
|
|
|
|
|
|
|
49
|
140
|
|
|
|
|
558
|
$class->SUPER::new(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub init($) |
53
|
140
|
|
|
140
|
0
|
360
|
{ my ($self, $args) = @_; |
54
|
|
|
|
|
|
|
|
55
|
140
|
|
|
|
|
447
|
$self->SUPER::init($args); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{MMH_field_type} = $args->{field_type} |
58
|
140
|
50
|
|
|
|
375
|
if $args->{field_type}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->message($args->{message}) |
61
|
140
|
100
|
|
|
|
345
|
if defined $args->{message}; |
62
|
|
|
|
|
|
|
|
63
|
140
|
|
|
|
|
296
|
$self->{MMH_fields} = {}; |
64
|
140
|
|
|
|
|
308
|
$self->{MMH_order} = []; |
65
|
140
|
|
50
|
|
|
500
|
$self->{MMH_modified} = $args->{modified} || 0; |
66
|
140
|
|
|
|
|
512
|
$self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub build(@) |
71
|
3
|
|
|
3
|
1
|
268
|
{ shift; |
72
|
3
|
|
|
|
|
29
|
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
|
94
|
{ my $self = shift; |
83
|
62
|
50
|
|
|
|
157
|
return $self->isModified unless @_; |
84
|
62
|
|
|
|
|
148
|
$self->{MMH_modified} = shift; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
1
|
0
|
sub isModified() { shift->{MMH_modified} } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
154
|
|
|
154
|
1
|
283
|
sub isEmpty { scalar keys %{shift->{MMH_fields}} } |
|
154
|
|
|
|
|
627
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub message(;$) |
95
|
123
|
|
|
123
|
1
|
203
|
{ my $self = shift; |
96
|
123
|
50
|
|
|
|
365
|
if(@_) |
97
|
123
|
|
|
|
|
261
|
{ $self->{MMH_message} = shift; |
98
|
123
|
|
|
|
|
367
|
weaken($self->{MMH_message}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
123
|
|
|
|
|
231
|
$self->{MMH_message}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
197
|
|
|
197
|
1
|
275
|
sub orderedFields() { grep defined $_, @{shift->{MMH_order}} } |
|
197
|
|
|
|
|
1140
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
10
|
|
|
10
|
1
|
15
|
sub knownNames() { keys %{shift->{MMH_fields}} } |
|
10
|
|
|
|
|
58
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#------------------------------------------ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get($;$) |
114
|
737
|
|
|
737
|
1
|
6564
|
{ my $known = shift->{MMH_fields}; |
115
|
737
|
|
|
|
|
1288
|
my $value = $known->{lc(shift)}; |
116
|
737
|
|
|
|
|
843
|
my $index = shift; |
117
|
|
|
|
|
|
|
|
118
|
737
|
100
|
|
|
|
1394
|
if(defined $index) |
|
|
100
|
|
|
|
|
|
119
|
160
|
50
|
|
|
|
566
|
{ 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
|
|
|
|
163
|
{ return ! defined $value ? () |
|
|
100
|
|
|
|
|
|
126
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? @$value |
127
|
|
|
|
|
|
|
: ($value); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else |
130
|
555
|
100
|
|
|
|
2457
|
{ 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
|
12
|
{ my $self = shift; |
142
|
2
|
100
|
|
|
|
8
|
return map {$_->study} $self->get(@_) |
|
3
|
|
|
|
|
11
|
|
143
|
|
|
|
|
|
|
if wantarray; |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
|
|
5
|
my $got = $self->get(@_); |
146
|
1
|
50
|
|
|
|
5
|
defined $got ? $got->study : undef; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#------------------------------------------ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub isMultipart() |
154
|
130
|
|
|
130
|
1
|
269
|
{ my $type = shift->get('Content-Type', 0); |
155
|
130
|
50
|
|
|
|
375
|
$type && scalar $type->body =~ m[^multipart/]i; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#------------------------------ |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub read($) |
161
|
12
|
|
|
12
|
1
|
23
|
{ my ($self, $parser) = @_; |
162
|
|
|
|
|
|
|
|
163
|
12
|
|
|
|
|
35
|
my @fields = $parser->readHeader; |
164
|
12
|
|
|
|
|
49
|
@$self{ qw/MMH_begin MMH_end/ } = (shift @fields, shift @fields); |
165
|
|
|
|
|
|
|
|
166
|
12
|
|
50
|
|
|
45
|
my $type = $self->{MMH_field_type} || 'Mail::Message::Field::Fast'; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self->addNoRealize($type->new( @$_ )) |
169
|
12
|
|
|
|
|
67
|
for @fields; |
170
|
|
|
|
|
|
|
|
171
|
12
|
|
|
|
|
61
|
$self; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Warning: fields are added in addResentGroup() as well! |
176
|
|
|
|
|
|
|
sub addOrderedFields(@) |
177
|
573
|
|
|
573
|
1
|
793
|
{ my $order = shift->{MMH_order}; |
178
|
573
|
|
|
|
|
900
|
foreach (@_) |
179
|
574
|
|
|
|
|
869
|
{ push @$order, $_; |
180
|
574
|
|
|
|
|
1481
|
weaken( $order->[-1] ); |
181
|
|
|
|
|
|
|
} |
182
|
573
|
|
|
|
|
899
|
@_; |
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
|
370
|
{ my ($self, $field) = @_; |
217
|
|
|
|
|
|
|
|
218
|
231
|
|
|
|
|
313
|
my $known = $self->{MMH_fields}; |
219
|
231
|
|
|
|
|
408
|
my $name = $field->name; |
220
|
|
|
|
|
|
|
|
221
|
231
|
|
|
|
|
505
|
$self->addOrderedFields($field); |
222
|
|
|
|
|
|
|
|
223
|
231
|
100
|
|
|
|
408
|
if(defined $known->{$name}) |
224
|
4
|
100
|
|
|
|
12
|
{ if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
225
|
3
|
|
|
|
|
8
|
else { $known->{$name} = [ $known->{$name}, $field ] } |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
else |
228
|
227
|
|
|
|
|
485
|
{ $known->{$name} = $field; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
231
|
|
|
|
|
541
|
$field; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
#------------------------------------------ |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |