| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mail::DKIM::MessageParser; |
|
2
|
15
|
|
|
15
|
|
134
|
use strict; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
561
|
|
|
3
|
15
|
|
|
15
|
|
75
|
use warnings; |
|
|
15
|
|
|
|
|
29
|
|
|
|
15
|
|
|
|
|
1175
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20240923'; # VERSION |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Signs/verifies Internet mail with DKIM/DomainKey signatures |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Copyright 2005 Messiah College. All rights reserved. |
|
8
|
|
|
|
|
|
|
# Jason Long |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Copyright (c) 2004 Anthony D. Urso. All rights reserved. |
|
11
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
12
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
13
|
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
115
|
use Carp; |
|
|
15
|
|
|
|
|
46
|
|
|
|
15
|
|
|
|
|
14593
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_object { |
|
17
|
1245
|
|
|
1245
|
0
|
3386
|
my $class = shift; |
|
18
|
1245
|
|
|
|
|
3735
|
return $class->TIEHANDLE(@_); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new_handle { |
|
22
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
|
23
|
0
|
|
|
|
|
0
|
local *TMP; |
|
24
|
0
|
|
|
|
|
0
|
tie *TMP, $class, @_; |
|
25
|
0
|
|
|
|
|
0
|
return *TMP; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub TIEHANDLE { |
|
29
|
1245
|
|
|
1245
|
|
2327
|
my $class = shift; |
|
30
|
1245
|
|
|
|
|
5131
|
my %args = @_; |
|
31
|
1245
|
|
|
|
|
2904
|
my $self = bless \%args, $class; |
|
32
|
1245
|
|
|
|
|
5079
|
$self->init; |
|
33
|
1243
|
|
|
|
|
10562
|
return $self; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init { |
|
37
|
1245
|
|
|
1245
|
0
|
2333
|
my $self = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1245
|
|
|
|
|
2268
|
my $buf = ''; |
|
40
|
1245
|
|
|
|
|
3185
|
$self->{buf_ref} = \$buf; |
|
41
|
1245
|
|
|
|
|
3375
|
$self->{in_header} = 1; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub PRINT { |
|
45
|
296
|
|
|
296
|
|
32109
|
my $self = shift; |
|
46
|
296
|
|
|
|
|
816
|
my $buf_ref = $self->{buf_ref}; |
|
47
|
296
|
50
|
|
|
|
2896
|
$$buf_ref .= @_ == 1 ? $_[0] : join( '', @_ ) if @_; |
|
|
|
50
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
296
|
50
|
|
|
|
1032
|
if ( $self->{in_header} ) { |
|
50
|
296
|
|
|
|
|
1181
|
local $1; # avoid polluting a global $1 |
|
51
|
296
|
|
|
|
|
1098
|
while ( $$buf_ref ne '' ) { |
|
52
|
3688
|
100
|
|
|
|
9995
|
if ( substr( $$buf_ref, 0, 2 ) eq "\015\012" ) { |
|
53
|
291
|
|
|
|
|
688
|
substr( $$buf_ref, 0, 2 ) = ''; |
|
54
|
291
|
|
|
|
|
1439
|
$self->finish_header(); |
|
55
|
291
|
|
|
|
|
788
|
$self->{in_header} = 0; |
|
56
|
291
|
|
|
|
|
1426
|
last; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
3397
|
100
|
|
|
|
17848
|
if ( $$buf_ref !~ /^(.+?\015\012)[^\ \t]/s ) { |
|
59
|
4
|
|
|
|
|
23
|
last; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
3393
|
|
|
|
|
23594
|
my $header = $1; |
|
62
|
3393
|
|
|
|
|
11813
|
$self->add_header($header); |
|
63
|
3393
|
|
|
|
|
11784
|
substr( $$buf_ref, 0, length($header) ) = ''; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
296
|
100
|
|
|
|
1089
|
if ( !$self->{in_header} ) { |
|
68
|
291
|
|
|
|
|
916
|
my $j = rindex( $$buf_ref, "\015\012" ); |
|
69
|
291
|
100
|
|
|
|
968
|
if ( $j >= 0 ) { |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# avoid copying a large buffer: the unterminated |
|
72
|
|
|
|
|
|
|
# last line is typically short compared to the rest |
|
73
|
|
|
|
|
|
|
|
|
74
|
290
|
|
|
|
|
970
|
my $carry = substr( $$buf_ref, $j + 2 ); |
|
75
|
290
|
|
|
|
|
895
|
substr( $$buf_ref, $j + 2 ) = ''; # shrink to last CRLF |
|
76
|
290
|
|
|
|
|
1644
|
$self->add_body($$buf_ref); # must end on CRLF |
|
77
|
290
|
|
|
|
|
842
|
$$buf_ref = $carry; # restore unterminated last line |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
296
|
|
|
|
|
1117
|
return 1; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub CLOSE { |
|
84
|
296
|
|
|
296
|
|
1672
|
my $self = shift; |
|
85
|
296
|
|
|
|
|
672
|
my $buf_ref = $self->{buf_ref}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
296
|
100
|
|
|
|
1079
|
if ( $self->{in_header} ) { |
|
88
|
5
|
100
|
|
|
|
25
|
if ( $$buf_ref ne '' ) { |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# A line of header text ending CRLF would not have been |
|
91
|
|
|
|
|
|
|
# processed yet since before we couldn't tell if it was |
|
92
|
|
|
|
|
|
|
# the complete header. Now that we're in CLOSE, we can |
|
93
|
|
|
|
|
|
|
# finish the header... |
|
94
|
4
|
|
|
|
|
483
|
$$buf_ref =~ s/\015\012\z//s; |
|
95
|
4
|
|
|
|
|
34
|
$self->add_header("$$buf_ref\015\012"); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
5
|
|
|
|
|
31
|
$self->finish_header; |
|
98
|
5
|
|
|
|
|
15
|
$self->{in_header} = 0; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
else { |
|
101
|
291
|
50
|
|
|
|
1007
|
if ( $$buf_ref ne '' ) { |
|
102
|
0
|
|
|
|
|
0
|
$self->add_body($$buf_ref); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
296
|
|
|
|
|
678
|
$$buf_ref = ''; |
|
106
|
296
|
|
|
|
|
1448
|
$self->finish_body; |
|
107
|
296
|
|
|
|
|
1248
|
return 1; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub add_header { |
|
111
|
0
|
|
|
0
|
0
|
|
die 'add_header not implemented'; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub finish_header { |
|
115
|
0
|
|
|
0
|
0
|
|
die 'finish_header not implemented'; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub add_body { |
|
119
|
0
|
|
|
0
|
0
|
|
die 'add_body not implemented'; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
0
|
0
|
|
sub finish_body { |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# do nothing by default |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub reset { |
|
128
|
0
|
|
|
0
|
0
|
|
carp 'reset not implemented'; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |