| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution Mail-Message version 4.04. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.06. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2001-2026 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Mail::Message::Head;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.04'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
40
|
|
|
40
|
|
22548
|
use parent 'Mail::Reporter'; |
|
|
40
|
|
|
|
|
84
|
|
|
|
40
|
|
|
|
|
322
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
40
|
|
|
40
|
|
3203
|
use strict; |
|
|
40
|
|
|
|
|
116
|
|
|
|
40
|
|
|
|
|
1158
|
|
|
19
|
40
|
|
|
40
|
|
258
|
use warnings; |
|
|
40
|
|
|
|
|
103
|
|
|
|
40
|
|
|
|
|
2730
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
40
|
|
|
40
|
|
314
|
use Log::Report 'mail-message', import => [ qw/mistake/ ]; |
|
|
40
|
|
|
|
|
71
|
|
|
|
40
|
|
|
|
|
298
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
40
|
|
|
40
|
|
7466
|
use Mail::Message::Head::Complete; |
|
|
40
|
|
|
|
|
101
|
|
|
|
40
|
|
|
|
|
1668
|
|
|
24
|
40
|
|
|
40
|
|
21881
|
use Mail::Message::Field::Fast; |
|
|
40
|
|
|
|
|
154
|
|
|
|
40
|
|
|
|
|
1959
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
40
|
|
|
40
|
|
293
|
use Scalar::Util qw/weaken/; |
|
|
40
|
|
|
|
|
82
|
|
|
|
40
|
|
|
|
|
3303
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#-------------------- |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use overload |
|
31
|
40
|
|
|
|
|
378
|
qq("") => 'string_unless_carp', |
|
32
|
40
|
|
|
40
|
|
289
|
bool => 'isEmpty'; |
|
|
40
|
|
|
|
|
102
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# To satisfy overload in static resolving. |
|
35
|
0
|
|
|
0
|
0
|
0
|
sub toString() { $_[0]->load->toString } |
|
36
|
0
|
|
|
0
|
0
|
0
|
sub string() { $_[0]->load->string } |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub string_unless_carp() |
|
39
|
0
|
|
|
0
|
0
|
0
|
{ my $self = shift; |
|
40
|
0
|
0
|
|
|
|
0
|
(caller)[0] eq 'Carp' or return $self->toString; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
my $class = ref $self =~ s/^Mail::Message/MM/r; |
|
43
|
0
|
|
|
|
|
0
|
"$class object"; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#-------------------- |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new(@) |
|
49
|
239
|
|
|
239
|
1
|
422534
|
{ my $class = shift; |
|
50
|
239
|
50
|
|
|
|
1938
|
$class eq __PACKAGE__ ? Mail::Message::Head::Complete->new(@_) : $class->SUPER::new(@_); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub init($) |
|
54
|
239
|
|
|
239
|
0
|
534
|
{ my ($self, $args) = @_; |
|
55
|
239
|
|
|
|
|
818
|
$self->SUPER::init($args); |
|
56
|
|
|
|
|
|
|
|
|
57
|
239
|
100
|
|
|
|
1067
|
$self->message($args->{message}) if defined $args->{message}; |
|
58
|
239
|
50
|
|
|
|
646
|
$self->{MMH_field_type} = $args->{field_type} if $args->{field_type}; |
|
59
|
239
|
|
|
|
|
1743
|
$self->{MMH_fields} = {}; |
|
60
|
239
|
|
|
|
|
597
|
$self->{MMH_order} = []; |
|
61
|
239
|
|
50
|
|
|
1174
|
$self->{MMH_modified} = $args->{modified} || 0; |
|
62
|
239
|
|
|
|
|
1151
|
$self; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub build(@) |
|
67
|
3
|
|
|
3
|
1
|
767958
|
{ shift; |
|
68
|
3
|
|
|
|
|
37
|
Mail::Message::Head::Complete->build(@_); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#-------------------- |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
1
|
0
|
sub isDelayed { 1 } |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub modified(;$) |
|
77
|
69
|
|
|
69
|
1
|
117
|
{ my $self = shift; |
|
78
|
69
|
50
|
|
|
|
216
|
return $self->isModified unless @_; |
|
79
|
69
|
|
|
|
|
157
|
$self->{MMH_modified} = shift; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
22
|
|
|
22
|
1
|
73
|
sub isModified() { $_[0]->{MMH_modified} } |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
453
|
|
|
453
|
1
|
1223
|
sub isEmpty { scalar keys %{ $_[0]->{MMH_fields}} } |
|
|
453
|
|
|
|
|
1883
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub message(;$) |
|
90
|
278
|
|
|
278
|
1
|
501
|
{ my $self = shift; |
|
91
|
278
|
50
|
|
|
|
672
|
if(@_) |
|
92
|
278
|
|
|
|
|
1175
|
{ $self->{MMH_message} = shift; |
|
93
|
278
|
|
|
|
|
604
|
weaken($self->{MMH_message}); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
278
|
|
|
|
|
600
|
$self->{MMH_message}; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
328
|
|
|
328
|
1
|
527
|
sub orderedFields() { grep defined, @{ $_[0]->{MMH_order}} } |
|
|
328
|
|
|
|
|
2738
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
34
|
|
|
34
|
1
|
58
|
sub knownNames() { keys %{ $_[0]->{MMH_fields}} } |
|
|
34
|
|
|
|
|
304
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#-------------------- |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get($;$) |
|
108
|
2773
|
|
|
2773
|
1
|
19194
|
{ my $known = shift->{MMH_fields}; |
|
109
|
2773
|
|
|
|
|
6672
|
my $value = $known->{lc(shift)}; |
|
110
|
2773
|
|
|
|
|
4158
|
my $index = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
2773
|
100
|
|
|
|
5744
|
if(defined $index) |
|
113
|
311
|
50
|
|
|
|
1621
|
{ return ! defined $value ? undef |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? $value->[$index] |
|
115
|
|
|
|
|
|
|
: $index == 0 ? $value |
|
116
|
|
|
|
|
|
|
: undef; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
2462
|
100
|
|
|
|
4952
|
if(wantarray) |
|
120
|
629
|
100
|
|
|
|
2599
|
{ return ! defined $value ? () |
|
|
|
100
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? @$value |
|
122
|
|
|
|
|
|
|
: ($value); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
1833
|
100
|
|
|
|
8390
|
! defined $value ? undef |
|
|
|
100
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
: ref $value eq 'ARRAY' ? $value->[-1] |
|
127
|
|
|
|
|
|
|
: $value; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
0
|
0
|
sub get_all(@) { my @all = shift->get(@_) } # compatibility, force list |
|
131
|
0
|
|
|
0
|
0
|
0
|
sub setField($$) {shift->add(@_)} # compatibility |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub study($;$) |
|
135
|
2
|
|
|
2
|
1
|
14
|
{ my $self = shift; |
|
136
|
2
|
100
|
|
|
|
9
|
return map $_->study, $self->get(@_) |
|
137
|
|
|
|
|
|
|
if wantarray; |
|
138
|
|
|
|
|
|
|
|
|
139
|
1
|
|
|
|
|
5
|
my $got = $self->get(@_); |
|
140
|
1
|
50
|
|
|
|
37
|
defined $got ? $got->study : undef; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#-------------------- |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub isMultipart() |
|
147
|
132
|
|
|
132
|
1
|
375
|
{ my $type = $_[0]->get('Content-Type', 0); |
|
148
|
132
|
50
|
|
|
|
445
|
$type && scalar $type->body =~ m[^multipart/]i; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#-------------------- |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub read($) |
|
154
|
74
|
|
|
74
|
1
|
209
|
{ my ($self, $parser) = @_; |
|
155
|
|
|
|
|
|
|
|
|
156
|
74
|
|
|
|
|
347
|
my @fields = $parser->readHeader; |
|
157
|
74
|
|
|
|
|
2101
|
@$self{ qw/MMH_begin MMH_end/ } = (shift @fields, shift @fields); |
|
158
|
|
|
|
|
|
|
|
|
159
|
74
|
|
50
|
|
|
341
|
my $type = $self->{MMH_field_type} // 'Mail::Message::Field::Fast'; |
|
160
|
|
|
|
|
|
|
|
|
161
|
74
|
|
|
|
|
569
|
$self->addNoRealize( $type->new(@$_) ) for @fields; |
|
162
|
74
|
|
|
|
|
851
|
$self; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Warning: fields are added in addResentGroup() as well! |
|
167
|
|
|
|
|
|
|
sub addOrderedFields(@) |
|
168
|
1367
|
|
|
1367
|
1
|
2499
|
{ my $order = shift->{MMH_order}; |
|
169
|
1367
|
|
|
|
|
2877
|
foreach (@_) |
|
170
|
1368
|
|
|
|
|
3774
|
{ push @$order, $_; |
|
171
|
1368
|
|
|
|
|
8529
|
weaken( $order->[-1] ); |
|
172
|
|
|
|
|
|
|
} |
|
173
|
1367
|
|
|
|
|
2600
|
@_; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
0
|
1
|
0
|
sub load($) { $_[0] } |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub fileLocation() |
|
181
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
182
|
0
|
|
|
|
|
0
|
@$self{ qw/MMH_begin MMH_end/ }; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub moveLocation($) |
|
187
|
0
|
|
|
0
|
1
|
0
|
{ my ($self, $dist) = @_; |
|
188
|
0
|
|
|
|
|
0
|
$self->{MMH_begin} -= $dist; |
|
189
|
0
|
|
|
|
|
0
|
$self->{MMH_end} -= $dist; |
|
190
|
0
|
|
|
|
|
0
|
$self; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub setNoRealize($) |
|
195
|
0
|
|
|
0
|
1
|
0
|
{ my ($self, $field) = @_; |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
0
|
my $known = $self->{MMH_fields}; |
|
198
|
0
|
|
|
|
|
0
|
my $name = $field->name; |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
0
|
$self->addOrderedFields($field); |
|
201
|
0
|
|
|
|
|
0
|
$known->{$name} = $field; |
|
202
|
0
|
|
|
|
|
0
|
$field; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub addNoRealize($) |
|
207
|
1007
|
|
|
1007
|
1
|
4972
|
{ my ($self, $field) = @_; |
|
208
|
|
|
|
|
|
|
|
|
209
|
1007
|
|
|
|
|
1867
|
my $known = $self->{MMH_fields}; |
|
210
|
1007
|
|
|
|
|
2445
|
my $name = $field->name; |
|
211
|
|
|
|
|
|
|
|
|
212
|
1007
|
|
|
|
|
2868
|
$self->addOrderedFields($field); |
|
213
|
|
|
|
|
|
|
|
|
214
|
1007
|
100
|
|
|
|
2368
|
if(defined $known->{$name}) |
|
215
|
72
|
100
|
|
|
|
218
|
{ if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field } |
|
|
44
|
|
|
|
|
68
|
|
|
|
44
|
|
|
|
|
121
|
|
|
216
|
28
|
|
|
|
|
99
|
else { $known->{$name} = [ $known->{$name}, $field ] } |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
else |
|
219
|
935
|
|
|
|
|
2407
|
{ $known->{$name} = $field; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
1007
|
|
|
|
|
3455
|
$field; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
#-------------------- |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; |