line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Attachment; |
2
|
40
|
|
|
40
|
|
245
|
use utf8; |
|
40
|
|
|
|
|
67
|
|
|
40
|
|
|
|
|
242
|
|
3
|
40
|
|
|
40
|
|
1385
|
use strictures; |
|
40
|
|
|
|
|
68
|
|
|
40
|
|
|
|
|
245
|
|
4
|
40
|
|
|
40
|
|
3884
|
use 5.10.00; |
|
40
|
|
|
|
|
113
|
|
|
40
|
|
|
|
|
1850
|
|
5
|
40
|
|
|
40
|
|
204
|
use MIME::Base64; |
|
40
|
|
|
|
|
62
|
|
|
40
|
|
|
|
|
2630
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
40
|
|
|
40
|
|
941
|
$Net::Gnats::Attachment::VERSION = '0.21'; |
9
|
|
|
|
|
|
|
} |
10
|
40
|
|
|
40
|
|
231
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
77
|
|
|
40
|
|
|
|
|
10920
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
3
|
|
|
3
|
0
|
6
|
my ($class, %options) = @_; |
14
|
3
|
|
|
|
|
7
|
my $self = bless \%options, $class; |
15
|
3
|
|
|
|
|
8
|
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; |