| 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::Box::Parser;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.04'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
41
|
|
|
41
|
|
942
|
use parent 'Mail::Reporter'; |
|
|
41
|
|
|
|
|
92
|
|
|
|
41
|
|
|
|
|
320
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
41
|
|
|
41
|
|
3693
|
use strict; |
|
|
41
|
|
|
|
|
119
|
|
|
|
41
|
|
|
|
|
1263
|
|
|
19
|
41
|
|
|
41
|
|
235
|
use warnings; |
|
|
41
|
|
|
|
|
97
|
|
|
|
41
|
|
|
|
|
4518
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
41
|
|
|
41
|
|
295
|
use Log::Report 'mail-message', import => [ qw/__x error/ ]; |
|
|
41
|
|
|
|
|
92
|
|
|
|
41
|
|
|
|
|
369
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#-------------------- |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new(@) |
|
26
|
20
|
|
|
20
|
1
|
2869
|
{ my $class = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
20
|
100
|
|
|
|
778
|
$class eq __PACKAGE__ |
|
29
|
|
|
|
|
|
|
? $class->defaultParserType->new(@_) # bootstrap right parser |
|
30
|
|
|
|
|
|
|
: $class->SUPER::new(@_); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init(@) |
|
34
|
18
|
|
|
18
|
0
|
71
|
{ my ($self, $args) = @_; |
|
35
|
18
|
|
|
|
|
94
|
$self->SUPER::init($args); |
|
36
|
|
|
|
|
|
|
|
|
37
|
18
|
|
|
|
|
133
|
$self->{MBP_trusted} = $args->{trusted}; |
|
38
|
18
|
|
|
|
|
58
|
$self->{MBP_fix} = $args->{fix_header_errors}; |
|
39
|
18
|
|
|
|
|
49
|
$self->{MBP_seps} = []; |
|
40
|
18
|
|
|
|
|
50
|
$self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#-------------------- |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub fixHeaderErrors(;$) |
|
46
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
47
|
0
|
0
|
|
|
|
0
|
@_ ? ($self->{MBP_fix} = shift) : $self->{MBPL_fix}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
45
|
|
|
45
|
1
|
145
|
sub trusted() { $_[0]->{MBP_trusted} } |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $parser_type; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub defaultParserType(;$) |
|
57
|
3
|
|
|
3
|
1
|
277033
|
{ my $class = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Select the parser manually? |
|
60
|
3
|
100
|
|
|
|
29
|
if(@_) |
|
61
|
1
|
|
|
|
|
4
|
{ $parser_type = shift; |
|
62
|
1
|
50
|
|
|
|
20
|
return $parser_type if $parser_type->isa( __PACKAGE__ ); |
|
63
|
0
|
|
|
|
|
0
|
error __x"parser {type} does not extend {pkg}.", type => $parser_type, pkg => __PACKAGE__; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Already determined which parser we want? |
|
67
|
|
|
|
|
|
|
$parser_type |
|
68
|
2
|
50
|
|
|
|
7
|
and return $parser_type; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Try to use C-based parser. |
|
71
|
2
|
|
|
|
|
180
|
eval 'require Mail::Box::Parser::C'; |
|
72
|
2
|
50
|
|
|
|
10134
|
$@ or return $parser_type = 'Mail::Box::Parser::C'; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Fall-back on Perl-based parser. |
|
75
|
0
|
|
|
|
|
0
|
require Mail::Box::Parser::Perl; |
|
76
|
0
|
|
|
|
|
0
|
$parser_type = 'Mail::Box::Parser::Perl'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#-------------------- |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
0
|
sub readHeader() { $_[0]->notImplemented } |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
0
|
1
|
0
|
sub bodyAsString() { $_[0]->notImplemented } |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
1
|
0
|
sub bodyAsList() { $_[0]->notImplemented } |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
0
|
sub bodyAsFile() { $_[0]->notImplemented } |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
1
|
0
|
sub bodyDelayed() { $_[0]->notImplemented } |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
1
|
0
|
sub lineSeparator() { $_[0]->{MBP_linesep} } |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
16
|
1
|
|
sub stop() { } |
|
100
|
|
|
|
|
|
|
sub filePosition() { undef } |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#-------------------- |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
0
|
sub readSeparator() { $_[0]->notImplemented } |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub pushSeparator($) |
|
108
|
10
|
|
|
10
|
1
|
26
|
{ my ($self, $sep) = @_; |
|
109
|
10
|
|
|
|
|
21
|
unshift @{$self->{MBP_seps}}, $sep; |
|
|
10
|
|
|
|
|
38
|
|
|
110
|
10
|
50
|
|
|
|
30
|
$self->{MBP_strip_gt}++ if $sep eq 'From '; |
|
111
|
10
|
|
|
|
|
21
|
$self; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub popSeparator() |
|
116
|
10
|
|
|
10
|
1
|
20
|
{ my $self = shift; |
|
117
|
10
|
|
|
|
|
16
|
my $sep = shift @{$self->{MBP_seps}}; |
|
|
10
|
|
|
|
|
30
|
|
|
118
|
10
|
50
|
|
|
|
58
|
$self->{MBP_strip_gt}-- if $sep eq 'From '; |
|
119
|
10
|
|
|
|
|
24
|
$sep; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
74
|
|
|
74
|
1
|
220
|
sub separators() { $_[0]->{MBP_seps} } |
|
124
|
29
|
|
|
29
|
1
|
68
|
sub activeSeparator() { $_[0]->separators->[0] } |
|
125
|
0
|
|
|
0
|
1
|
0
|
sub resetSeparators() { $_[0]->{MBP_seps} = []; $_[0]->{MBP_strip_gt} = 0 } |
|
|
0
|
|
|
|
|
0
|
|
|
126
|
45
|
|
|
45
|
1
|
131
|
sub stripGt { $_[0]->{MBP_strip_gt} } |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#-------------------- |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#-------------------- |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |