line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Lite::Processor::ParseRfc822; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
119
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Mail::Lite::Constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
7
|
1
|
|
|
1
|
|
6
|
use Smart::Comments -ENV; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub process { |
11
|
4
|
|
|
4
|
0
|
8
|
my $args_ref = shift; |
12
|
4
|
|
|
|
|
10
|
my ( $processor, $messages ) = @$args_ref{ qw/processor input/ }; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
### $messages |
15
|
|
|
|
|
|
|
|
16
|
4
|
100
|
|
|
|
18
|
ref $messages eq 'ARRAY' |
17
|
|
|
|
|
|
|
or $messages = [ $messages ]; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
7
|
my @output; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
11
|
foreach my $message (@$messages) { |
22
|
|
|
|
|
|
|
### $message |
23
|
5
|
|
|
|
|
21
|
my @lines = split /\n\s*/, $message->body; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
13
|
my $parsed = {}; |
26
|
|
|
|
|
|
|
|
27
|
5
|
|
|
|
|
12
|
foreach (@lines) { |
28
|
15
|
100
|
|
|
|
34
|
next unless length; |
29
|
|
|
|
|
|
|
|
30
|
13
|
|
|
|
|
65
|
my ($key, $val) = /\s*(.+?):\s+(.+)/; |
31
|
|
|
|
|
|
|
|
32
|
13
|
50
|
|
|
|
33
|
next unless defined $key; |
33
|
|
|
|
|
|
|
|
34
|
13
|
|
|
|
|
22
|
$key = lc $key; |
35
|
13
|
|
|
|
|
23
|
$key =~ tr/-/_/; |
36
|
|
|
|
|
|
|
|
37
|
13
|
100
|
|
|
|
33
|
unless (exists($parsed->{$key})) { |
38
|
10
|
|
|
|
|
36
|
$parsed->{$key} = $val; |
39
|
|
|
|
|
|
|
} else { |
40
|
3
|
100
|
|
|
|
9
|
if (ref $parsed->{$key} eq 'ARRAY') { |
41
|
1
|
|
|
|
|
2
|
push @{$parsed->{$key}}, $val; |
|
1
|
|
|
|
|
5
|
|
42
|
|
|
|
|
|
|
} else { |
43
|
2
|
|
|
|
|
9
|
$parsed->{$key} = [ $parsed->{$key}, $val ]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
20
|
push @output, $parsed; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
8
|
${ $args_ref->{ output } } = \@output; |
|
4
|
|
|
|
|
9
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
15
|
return OK; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |