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::Head; |
10
|
38
|
|
|
38
|
|
335
|
use vars '$VERSION'; |
|
38
|
|
|
|
|
89
|
|
|
38
|
|
|
|
|
1967
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.013'; |
12
|
|
|
|
|
|
|
|
13
|
38
|
|
|
38
|
|
226
|
use base 'Mail::Reporter'; |
|
38
|
|
|
|
|
77
|
|
|
38
|
|
|
|
|
5441
|
|
14
|
|
|
|
|
|
|
|
15
|
38
|
|
|
38
|
|
285
|
use strict; |
|
38
|
|
|
|
|
100
|
|
|
38
|
|
|
|
|
1013
|
|
16
|
38
|
|
|
38
|
|
225
|
use warnings; |
|
38
|
|
|
|
|
92
|
|
|
38
|
|
|
|
|
1246
|
|
17
|
|
|
|
|
|
|
|
18
|
38
|
|
|
38
|
|
288
|
use Mail::Message::Head::Complete; |
|
38
|
|
|
|
|
80
|
|
|
38
|
|
|
|
|
1232
|
|
19
|
38
|
|
|
38
|
|
18369
|
use Mail::Message::Field::Fast; |
|
38
|
|
|
|
|
119
|
|
|
38
|
|
|
|
|
1152
|
|
20
|
|
|
|
|
|
|
|
21
|
38
|
|
|
38
|
|
248
|
use Carp; |
|
38
|
|
|
|
|
85
|
|
|
38
|
|
|
|
|
2163
|
|
22
|
38
|
|
|
38
|
|
226
|
use Scalar::Util 'weaken'; |
|
38
|
|
|
|
|
73
|
|
|
38
|
|
|
|
|
1956
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
38
|
|
|
|
|
187
|
use overload qq("") => 'string_unless_carp' |
26
|
38
|
|
|
38
|
|
247
|
, bool => 'isEmpty'; |
|
38
|
|
|
|
|
94
|
|
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
|
170
|
|
|
170
|
1
|
483
|
{ my $class = shift; |
45
|
|
|
|
|
|
|
|
46
|
170
|
50
|
|
|
|
452
|
return Mail::Message::Head::Complete->new(@_) |
47
|
|
|
|
|
|
|
if $class eq __PACKAGE__; |
48
|
|
|
|
|
|
|
|
49
|
170
|
|
|
|
|
649
|
$class->SUPER::new(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub init($) |
53
|
170
|
|
|
170
|
0
|
367
|
{ my ($self, $args) = @_; |
54
|
|
|
|
|
|
|
|
55
|
170
|
|
|
|
|
498
|
$self->SUPER::init($args); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{MMH_field_type} = $args->{field_type} |
58
|
170
|
50
|
|
|
|
447
|
if $args->{field_type}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->message($args->{message}) |
61
|
170
|
100
|
|
|
|
484
|
if defined $args->{message}; |
62
|
|
|
|
|
|
|
|
63
|
170
|
|
|
|
|
366
|
$self->{MMH_fields} = {}; |
64
|
170
|
|
|
|
|
376
|
$self->{MMH_order} = []; |
65
|
170
|
|
50
|
|
|
621
|
$self->{MMH_modified} = $args->{modified} || 0; |
66
|
170
|
|
|
|
|
763
|
$self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub build(@) |
71
|
3
|
|
|
3
|
1
|
689
|
{ 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
|
71
|
|
|
71
|
1
|
115
|
{ my $self = shift; |
83
|
71
|
50
|
|
|
|
153
|
return $self->isModified unless @_; |
84
|
71
|
|
|
|
|
156
|
$self->{MMH_modified} = shift; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
1
|
0
|
sub isModified() { shift->{MMH_modified} } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
215
|
|
|
215
|
1
|
453
|
sub isEmpty { scalar keys %{shift->{MMH_fields}} } |
|
215
|
|
|
|
|
782
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub message(;$) |
95
|
167
|
|
|
167
|
1
|
309
|
{ my $self = shift; |
96
|
167
|
50
|
|
|
|
426
|
if(@_) |
97
|
167
|
|
|
|
|
316
|
{ $self->{MMH_message} = shift; |
98
|
167
|
|
|
|
|
535
|
weaken($self->{MMH_message}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
167
|
|
|
|
|
346
|
$self->{MMH_message}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
213
|
|
|
213
|
1
|
323
|
sub orderedFields() { grep defined $_, @{shift->{MMH_order}} } |
|
213
|
|
|
|
|
1292
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
19
|
|
|
19
|
1
|
33
|
sub knownNames() { keys %{shift->{MMH_fields}} } |
|
19
|
|
|
|
|
134
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#------------------------------------------ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get($;$) |
114
|
954
|
|
|
954
|
1
|
9368
|
{ my $known = shift->{MMH_fields}; |
115
|
954
|
|
|
|
|
1878
|
my $value = $known->{lc(shift)}; |
116
|
954
|
|
|
|
|
1323
|
my $index = shift; |
117
|
|
|
|
|
|
|
|
118
|
954
|
100
|
|
|
|
2048
|
if(defined $index) |
|
|
100
|
|
|
|
|
|
119
|
198
|
50
|
|
|
|
821
|
{ 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
|
|
|
|
136
|
{ return ! defined $value ? () |
|
|
100
|
|
|
|
|
|
126
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? @$value |
127
|
|
|
|
|
|
|
: ($value); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else |
130
|
734
|
100
|
|
|
|
3219
|
{ 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
|
|
|
|
10
|
return map {$_->study} $self->get(@_) |
|
3
|
|
|
|
|
13
|
|
143
|
|
|
|
|
|
|
if wantarray; |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
|
|
5
|
my $got = $self->get(@_); |
146
|
1
|
50
|
|
|
|
6
|
defined $got ? $got->study : undef; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#------------------------------------------ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub isMultipart() |
154
|
130
|
|
|
130
|
1
|
283
|
{ my $type = shift->get('Content-Type', 0); |
155
|
130
|
50
|
|
|
|
438
|
$type && scalar $type->body =~ m[^multipart/]i; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#------------------------------ |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub read($) |
161
|
26
|
|
|
26
|
1
|
59
|
{ my ($self, $parser) = @_; |
162
|
|
|
|
|
|
|
|
163
|
26
|
|
|
|
|
93
|
my @fields = $parser->readHeader; |
164
|
26
|
|
|
|
|
139
|
@$self{ qw/MMH_begin MMH_end/ } = (shift @fields, shift @fields); |
165
|
|
|
|
|
|
|
|
166
|
26
|
|
50
|
|
|
110
|
my $type = $self->{MMH_field_type} || 'Mail::Message::Field::Fast'; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self->addNoRealize($type->new( @$_ )) |
169
|
26
|
|
|
|
|
169
|
for @fields; |
170
|
|
|
|
|
|
|
|
171
|
26
|
|
|
|
|
153
|
$self; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Warning: fields are added in addResentGroup() as well! |
176
|
|
|
|
|
|
|
sub addOrderedFields(@) |
177
|
644
|
|
|
644
|
1
|
1096
|
{ my $order = shift->{MMH_order}; |
178
|
644
|
|
|
|
|
1169
|
foreach (@_) |
179
|
645
|
|
|
|
|
1126
|
{ push @$order, $_; |
180
|
645
|
|
|
|
|
1835
|
weaken( $order->[-1] ); |
181
|
|
|
|
|
|
|
} |
182
|
644
|
|
|
|
|
1095
|
@_; |
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
|
285
|
|
|
285
|
1
|
515
|
{ my ($self, $field) = @_; |
217
|
|
|
|
|
|
|
|
218
|
285
|
|
|
|
|
451
|
my $known = $self->{MMH_fields}; |
219
|
285
|
|
|
|
|
566
|
my $name = $field->name; |
220
|
|
|
|
|
|
|
|
221
|
285
|
|
|
|
|
713
|
$self->addOrderedFields($field); |
222
|
|
|
|
|
|
|
|
223
|
285
|
100
|
|
|
|
591
|
if(defined $known->{$name}) |
224
|
4
|
100
|
|
|
|
13
|
{ if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
225
|
3
|
|
|
|
|
8
|
else { $known->{$name} = [ $known->{$name}, $field ] } |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
else |
228
|
281
|
|
|
|
|
556
|
{ $known->{$name} = $field; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
285
|
|
|
|
|
766
|
$field; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
#------------------------------------------ |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |