line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Attachment; |
2
|
40
|
|
|
40
|
|
179
|
use utf8; |
|
40
|
|
|
|
|
65
|
|
|
40
|
|
|
|
|
203
|
|
3
|
40
|
|
|
40
|
|
1092
|
use strictures; |
|
40
|
|
|
|
|
66
|
|
|
40
|
|
|
|
|
199
|
|
4
|
40
|
|
|
40
|
|
2456
|
use 5.10.00; |
|
40
|
|
|
|
|
125
|
|
|
40
|
|
|
|
|
1547
|
|
5
|
40
|
|
|
40
|
|
174
|
use MIME::Base64; |
|
40
|
|
|
|
|
76
|
|
|
40
|
|
|
|
|
2423
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
40
|
|
|
40
|
|
855
|
$Net::Gnats::Attachment::VERSION = '0.20'; |
9
|
|
|
|
|
|
|
} |
10
|
40
|
|
|
40
|
|
252
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
51
|
|
|
40
|
|
|
|
|
10501
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
3
|
|
|
3
|
0
|
7
|
my ($class, %options) = @_; |
14
|
3
|
|
|
|
|
6
|
my $self = bless \%options, $class; |
15
|
3
|
|
|
|
|
9
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
|
sub encode { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub decode { |
23
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Split the envelope from the body. |
26
|
0
|
|
|
|
|
|
my ($envelope, $body) = split(/\n\n/, $self->{payload}, 2); |
27
|
0
|
0
|
0
|
|
|
|
return undef unless ($envelope && $body); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $ex_envelope = qr{\sContent-Type:\s(.*)\n |
30
|
|
|
|
|
|
|
\sContent-Transfer-Encoding:\s(.*)\n |
31
|
|
|
|
|
|
|
\sContent-Disposition:\s(.*)\n}x; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
($self->{content_type}, |
34
|
|
|
|
|
|
|
$self->{content_transfer_encoding}, |
35
|
|
|
|
|
|
|
$self->{content_disposition}) = $envelope =~ $ex_envelope; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ( $self->{content_transfer_encoding} eq 'base64') { |
38
|
0
|
|
|
|
|
|
$self->{data} = decode_base64($body); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
$self->{data} = $body; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |