line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::MessageParser; |
2
|
14
|
|
|
14
|
|
122
|
use strict; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
412
|
|
3
|
14
|
|
|
14
|
|
68
|
use warnings; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
565
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230911'; # 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
|
14
|
|
|
14
|
|
85
|
use Carp; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
10249
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_object { |
17
|
1238
|
|
|
1238
|
0
|
2759
|
my $class = shift; |
18
|
1238
|
|
|
|
|
2741
|
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
|
1238
|
|
|
1238
|
|
1809
|
my $class = shift; |
30
|
1238
|
|
|
|
|
3842
|
my %args = @_; |
31
|
1238
|
|
|
|
|
2832
|
my $self = bless \%args, $class; |
32
|
1238
|
|
|
|
|
3855
|
$self->init; |
33
|
1236
|
|
|
|
|
5452
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init { |
37
|
1238
|
|
|
1238
|
0
|
1850
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
1238
|
|
|
|
|
1818
|
my $buf = ''; |
40
|
1238
|
|
|
|
|
2535
|
$self->{buf_ref} = \$buf; |
41
|
1238
|
|
|
|
|
2800
|
$self->{in_header} = 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub PRINT { |
45
|
293
|
|
|
293
|
|
22243
|
my $self = shift; |
46
|
293
|
|
|
|
|
625
|
my $buf_ref = $self->{buf_ref}; |
47
|
293
|
50
|
|
|
|
1719
|
$$buf_ref .= @_ == 1 ? $_[0] : join( '', @_ ) if @_; |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
293
|
50
|
|
|
|
821
|
if ( $self->{in_header} ) { |
50
|
293
|
|
|
|
|
1374
|
local $1; # avoid polluting a global $1 |
51
|
293
|
|
|
|
|
770
|
while ( $$buf_ref ne '' ) { |
52
|
3674
|
100
|
|
|
|
7895
|
if ( substr( $$buf_ref, 0, 2 ) eq "\015\012" ) { |
53
|
288
|
|
|
|
|
526
|
substr( $$buf_ref, 0, 2 ) = ''; |
54
|
288
|
|
|
|
|
950
|
$self->finish_header(); |
55
|
288
|
|
|
|
|
588
|
$self->{in_header} = 0; |
56
|
288
|
|
|
|
|
843
|
last; |
57
|
|
|
|
|
|
|
} |
58
|
3386
|
100
|
|
|
|
14020
|
if ( $$buf_ref !~ /^(.+?\015\012)[^\ \t]/s ) { |
59
|
4
|
|
|
|
|
13
|
last; |
60
|
|
|
|
|
|
|
} |
61
|
3382
|
|
|
|
|
8177
|
my $header = $1; |
62
|
3382
|
|
|
|
|
8833
|
$self->add_header($header); |
63
|
3382
|
|
|
|
|
9793
|
substr( $$buf_ref, 0, length($header) ) = ''; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
293
|
100
|
|
|
|
785
|
if ( !$self->{in_header} ) { |
68
|
288
|
|
|
|
|
668
|
my $j = rindex( $$buf_ref, "\015\012" ); |
69
|
288
|
100
|
|
|
|
629
|
if ( $j >= 0 ) { |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# avoid copying a large buffer: the unterminated |
72
|
|
|
|
|
|
|
# last line is typically short compared to the rest |
73
|
|
|
|
|
|
|
|
74
|
287
|
|
|
|
|
698
|
my $carry = substr( $$buf_ref, $j + 2 ); |
75
|
287
|
|
|
|
|
568
|
substr( $$buf_ref, $j + 2 ) = ''; # shrink to last CRLF |
76
|
287
|
|
|
|
|
1066
|
$self->add_body($$buf_ref); # must end on CRLF |
77
|
287
|
|
|
|
|
616
|
$$buf_ref = $carry; # restore unterminated last line |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
293
|
|
|
|
|
746
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub CLOSE { |
84
|
293
|
|
|
293
|
|
1167
|
my $self = shift; |
85
|
293
|
|
|
|
|
533
|
my $buf_ref = $self->{buf_ref}; |
86
|
|
|
|
|
|
|
|
87
|
293
|
100
|
|
|
|
702
|
if ( $self->{in_header} ) { |
88
|
5
|
100
|
|
|
|
22
|
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
|
|
|
|
|
19
|
$$buf_ref =~ s/\015\012\z//s; |
95
|
4
|
|
|
|
|
25
|
$self->add_header("$$buf_ref\015\012"); |
96
|
|
|
|
|
|
|
} |
97
|
5
|
|
|
|
|
26
|
$self->finish_header; |
98
|
5
|
|
|
|
|
11
|
$self->{in_header} = 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
288
|
50
|
|
|
|
690
|
if ( $$buf_ref ne '' ) { |
102
|
0
|
|
|
|
|
0
|
$self->add_body($$buf_ref); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
293
|
|
|
|
|
522
|
$$buf_ref = ''; |
106
|
293
|
|
|
|
|
966
|
$self->finish_body; |
107
|
293
|
|
|
|
|
719
|
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__ |