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::Field::Structured; |
10
|
22
|
|
|
22
|
|
2422
|
use vars '$VERSION'; |
|
22
|
|
|
|
|
53
|
|
|
22
|
|
|
|
|
1204
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.013'; |
12
|
|
|
|
|
|
|
|
13
|
22
|
|
|
22
|
|
136
|
use base 'Mail::Message::Field::Full'; |
|
22
|
|
|
|
|
78
|
|
|
22
|
|
|
|
|
5580
|
|
14
|
|
|
|
|
|
|
|
15
|
22
|
|
|
22
|
|
176
|
use strict; |
|
22
|
|
|
|
|
51
|
|
|
22
|
|
|
|
|
583
|
|
16
|
22
|
|
|
22
|
|
113
|
use warnings; |
|
22
|
|
|
|
|
52
|
|
|
22
|
|
|
|
|
788
|
|
17
|
|
|
|
|
|
|
|
18
|
22
|
|
|
22
|
|
10083
|
use Mail::Message::Field::Attribute; |
|
22
|
|
|
|
|
65
|
|
|
22
|
|
|
|
|
822
|
|
19
|
22
|
|
|
22
|
|
154
|
use Storable 'dclone'; |
|
22
|
|
|
|
|
54
|
|
|
22
|
|
|
|
|
21581
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init($) |
23
|
112
|
|
|
112
|
0
|
261
|
{ my ($self, $args) = @_; |
24
|
112
|
|
|
|
|
951
|
$self->{MMFS_attrs} = {}; |
25
|
112
|
|
|
|
|
282
|
$self->{MMFS_datum} = $args->{datum}; |
26
|
|
|
|
|
|
|
|
27
|
112
|
|
|
|
|
455
|
$self->SUPER::init($args); |
28
|
|
|
|
|
|
|
|
29
|
112
|
|
50
|
|
|
478
|
my $attr = $args->{attributes} || []; |
30
|
112
|
50
|
|
|
|
414
|
$attr = [ %$attr ] if ref $attr eq 'HASH'; |
31
|
|
|
|
|
|
|
|
32
|
112
|
|
|
|
|
321
|
while(@$attr) |
33
|
0
|
|
|
|
|
0
|
{ my $name = shift @$attr; |
34
|
0
|
0
|
|
|
|
0
|
if(ref $name) { $self->attribute($name) } |
|
0
|
|
|
|
|
0
|
|
35
|
0
|
|
|
|
|
0
|
else { $self->attribute($name, shift @$attr) } |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
112
|
|
|
|
|
715
|
$self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
195
|
|
|
195
|
1
|
10833
|
sub clone() { dclone(shift) } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#------------------------------------------ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub attribute($;$) |
47
|
307
|
|
|
307
|
1
|
2667
|
{ my ($self, $attr) = (shift, shift); |
48
|
307
|
|
|
|
|
470
|
my $name; |
49
|
307
|
100
|
|
|
|
805
|
if(ref $attr) { $name = $attr->name } |
|
72
|
100
|
|
|
|
178
|
|
50
|
192
|
|
|
|
|
838
|
elsif( !@_ ) { return $self->{MMFS_attrs}{lc $attr} } |
51
|
|
|
|
|
|
|
else |
52
|
43
|
|
|
|
|
88
|
{ $name = $attr; |
53
|
43
|
|
|
|
|
176
|
$attr = Mail::Message::Field::Attribute->new($name, @_); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
115
|
|
|
|
|
231
|
delete $self->{MMFF_body}; |
57
|
115
|
|
|
|
|
378
|
$self->{MMFS_attrs}{lc $name} = $attr; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
2
|
1
|
5
|
sub attributes() { values %{shift->{MMFS_attrs}} } |
|
2
|
|
|
|
|
11
|
|
62
|
7
|
|
|
7
|
1
|
24
|
sub beautify() { delete shift->{MMFF_body} } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
0
|
sub attrPairs() { map +($_->name, $_->value), shift->attributes } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#------------------------- |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub parse($) |
71
|
78
|
|
|
78
|
1
|
177
|
{ my ($self, $string) = @_; |
72
|
|
|
|
|
|
|
|
73
|
78
|
|
|
|
|
182
|
for($string) |
74
|
|
|
|
|
|
|
{ # remove FWS, even within quoted strings |
75
|
78
|
|
|
|
|
192
|
s/\r?\n(\s)/$1/gs; |
76
|
78
|
|
|
|
|
393
|
s/\r?\n/ /gs; |
77
|
78
|
|
|
|
|
392
|
s/\s+$//; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
78
|
|
|
|
|
155
|
my $datum = ''; |
81
|
78
|
|
100
|
|
|
397
|
while(length $string && substr($string, 0, 1) ne ';') |
82
|
80
|
|
|
|
|
292
|
{ (undef, $string) = $self->consumeComment($string); |
83
|
80
|
100
|
|
|
|
730
|
$datum .= $1 if $string =~ s/^([^;(]+)//; |
84
|
|
|
|
|
|
|
} |
85
|
78
|
|
|
|
|
184
|
$self->{MMFS_datum} = $datum; |
86
|
|
|
|
|
|
|
|
87
|
78
|
|
|
|
|
143
|
my $found = ''; |
88
|
78
|
|
|
|
|
276
|
while($string =~ m/\S/) |
89
|
147
|
|
|
|
|
282
|
{ my $len = length $string; |
90
|
|
|
|
|
|
|
|
91
|
147
|
100
|
100
|
|
|
691
|
if($string =~ s/^\s*\;\s*// && length $found) |
92
|
5
|
|
|
|
|
20
|
{ my ($name) = $found =~ m/^([^*]+)\*/; |
93
|
5
|
100
|
100
|
|
|
21
|
if($name && (my $cont = $self->attribute($name))) |
94
|
1
|
|
|
|
|
4
|
{ $cont->addComponent($found); # continuation |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else |
97
|
4
|
|
|
|
|
16
|
{ my $attr = Mail::Message::Field::Attribute->new($found); |
98
|
4
|
|
|
|
|
12
|
$self->attribute($attr); |
99
|
|
|
|
|
|
|
} |
100
|
5
|
|
|
|
|
22
|
$found = ''; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
147
|
|
|
|
|
413
|
(undef, $string) = $self->consumeComment($string); |
104
|
147
|
|
|
|
|
312
|
$string =~ s/^\n//; |
105
|
147
|
|
|
|
|
437
|
(my $text, $string) = $self->consumePhrase($string); |
106
|
147
|
100
|
|
|
|
423
|
$found .= $text if defined $text; |
107
|
|
|
|
|
|
|
|
108
|
147
|
50
|
|
|
|
517
|
if(length($string) == $len) |
109
|
|
|
|
|
|
|
{ # nothing consumed, remove character to avoid endless loop |
110
|
0
|
|
|
|
|
0
|
$string =~ s/^\s*\S//; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
78
|
100
|
|
|
|
189
|
if(length $found) |
115
|
70
|
|
|
|
|
164
|
{ my ($name) = $found =~ m/^([^*]+)\*/; |
116
|
70
|
100
|
66
|
|
|
206
|
if($name && (my $cont = $self->attribute($name))) |
117
|
2
|
|
|
|
|
7
|
{ $cont->addComponent($found); # continuation |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else |
120
|
68
|
|
|
|
|
299
|
{ my $attr = Mail::Message::Field::Attribute->new($found); |
121
|
68
|
|
|
|
|
192
|
$self->attribute($attr); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
78
|
|
|
|
|
186
|
1; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub produceBody() |
129
|
49
|
|
|
49
|
1
|
546
|
{ my $self = shift; |
130
|
49
|
|
|
|
|
96
|
my $attrs = $self->{MMFS_attrs}; |
131
|
49
|
|
|
|
|
94
|
my $datum = $self->{MMFS_datum}; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
join '; ' |
134
|
|
|
|
|
|
|
, (defined $datum ? $datum : '') |
135
|
49
|
100
|
|
|
|
223
|
, map {$_->string} @{$attrs}{sort keys %$attrs}; |
|
47
|
|
|
|
|
174
|
|
|
49
|
|
|
|
|
137
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub datum(@) |
140
|
2
|
|
|
2
|
1
|
424
|
{ my $self = shift; |
141
|
2
|
100
|
|
|
|
12
|
@_ or return $self->{MMFS_datum}; |
142
|
1
|
|
|
|
|
3
|
delete $self->{MMFF_body}; |
143
|
1
|
|
|
|
|
6
|
$self->{MMFS_datum} = shift; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |