line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Decoder::UU; |
2
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
73
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
134
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MIME::Decoder::UU - decode a "uuencoded" stream |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
A generic decoder object; see L for usage. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Also supports a preamble() method to recover text before |
15
|
|
|
|
|
|
|
the uuencoded portion of the stream. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
A MIME::Decoder subclass for a nonstandard encoding whereby |
21
|
|
|
|
|
|
|
data are uuencoded. Common non-standard MIME encodings for this: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
x-uu |
24
|
|
|
|
|
|
|
x-uuencode |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SEE ALSO |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
L |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 AUTHOR |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Eryq (F), ZeeGee Software Inc (F). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
UU-decoding code lifted from "uuexplode", a Perl script by an |
35
|
|
|
|
|
|
|
unknown author... |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
All rights reserved. This program is free software; you can redistribute |
38
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
require 5.002; |
44
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA $VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
45
|
2
|
|
|
2
|
|
10
|
use MIME::Decoder; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
55
|
|
46
|
2
|
|
|
2
|
|
11
|
use MIME::Tools qw(whine); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1468
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
@ISA = qw(MIME::Decoder); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# The package version, both in 1.23 style *and* usable by MakeMaker: |
51
|
|
|
|
|
|
|
$VERSION = "5.507"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#------------------------------ |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# decode_it IN, OUT |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
sub decode_it { |
59
|
7
|
|
|
7
|
1
|
15
|
my ($self, $in, $out) = @_; |
60
|
7
|
|
|
|
|
11
|
my ($mode, $file); |
61
|
0
|
|
|
|
|
0
|
my @preamble; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
### Init: |
64
|
7
|
|
|
|
|
22
|
$self->{MDU_Preamble} = \@preamble; |
65
|
7
|
|
|
|
|
18
|
$self->{MDU_Mode} = undef; |
66
|
7
|
|
|
|
|
13
|
$self->{MDU_File} = undef; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
### Find beginning... |
69
|
7
|
|
|
|
|
11
|
local $_; |
70
|
7
|
|
|
|
|
303
|
while (defined($_ = $in->getline)) { |
71
|
16
|
100
|
|
|
|
472
|
if (/^begin(.*)/) { ### found it: now decode it... |
72
|
5
|
|
|
|
|
11
|
my $modefile = $1; |
73
|
5
|
50
|
|
|
|
38
|
if ($modefile =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/) { |
74
|
5
|
|
|
|
|
17
|
($mode, $file) = ($2, $4); |
75
|
|
|
|
|
|
|
} |
76
|
5
|
|
|
|
|
10
|
last; ### decoded or not, we're done |
77
|
|
|
|
|
|
|
} |
78
|
11
|
|
|
|
|
211
|
push @preamble, $_; |
79
|
|
|
|
|
|
|
} |
80
|
7
|
100
|
|
|
|
97
|
die("uu decoding: no begin found\n") if !defined($_); # hit eof! |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
### Store info: |
83
|
5
|
|
|
|
|
14
|
$self->{MDU_Mode} = $mode; |
84
|
5
|
|
|
|
|
11
|
$self->{MDU_File} = $file; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
### Decode: |
87
|
5
|
|
|
|
|
108
|
while (defined($_ = $in->getline)) { |
88
|
299
|
100
|
|
|
|
14348
|
last if /^end/; |
89
|
294
|
50
|
|
|
|
835
|
next if /[a-z]/; |
90
|
294
|
50
|
|
|
|
852
|
next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); |
91
|
294
|
|
|
|
|
1137
|
$out->print(unpack('u', $_)); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
### chmod oct($mode), $file; # sheeyeah... right... |
94
|
5
|
50
|
|
|
|
18
|
whine "file incomplete, no end found\n" if !defined($_); # eof |
95
|
5
|
|
|
|
|
24
|
1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#------------------------------ |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# encode_it IN, OUT |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
sub encode_it { |
103
|
1
|
|
|
1
|
1
|
3
|
my ($self, $in, $out) = @_; |
104
|
1
|
|
|
|
|
3
|
my $buf = ''; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
50
|
|
|
9
|
my $fname = (($self->head && |
107
|
|
|
|
|
|
|
$self->head->mime_attr('content-disposition.filename')) || |
108
|
|
|
|
|
|
|
''); |
109
|
1
|
|
|
|
|
7
|
$out->print("begin 644 $fname\n"); |
110
|
1
|
|
|
|
|
13
|
while ($in->read($buf, 45)) { $out->print(pack('u', $buf)) } |
|
68
|
|
|
|
|
997
|
|
111
|
1
|
|
|
|
|
16
|
$out->print("end\n"); |
112
|
1
|
|
|
|
|
13
|
1; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#------------------------------ |
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
# last_preamble |
118
|
|
|
|
|
|
|
# |
119
|
|
|
|
|
|
|
# Return the last preamble as ref to array of lines. |
120
|
|
|
|
|
|
|
# Gets reset by decode_it(). |
121
|
|
|
|
|
|
|
# |
122
|
|
|
|
|
|
|
sub last_preamble { |
123
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
124
|
4
|
|
50
|
|
|
17
|
return $self->{MDU_Preamble} || []; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#------------------------------ |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
# last_mode |
130
|
|
|
|
|
|
|
# |
131
|
|
|
|
|
|
|
# Return the last mode. |
132
|
|
|
|
|
|
|
# Gets reset to undef by decode_it(). |
133
|
|
|
|
|
|
|
# |
134
|
|
|
|
|
|
|
sub last_mode { |
135
|
4
|
|
|
4
|
0
|
14
|
shift->{MDU_Mode}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#------------------------------ |
139
|
|
|
|
|
|
|
# |
140
|
|
|
|
|
|
|
# last_filename |
141
|
|
|
|
|
|
|
# |
142
|
|
|
|
|
|
|
# Return the last filename. |
143
|
|
|
|
|
|
|
# Gets reset by decode_it(). |
144
|
|
|
|
|
|
|
# |
145
|
|
|
|
|
|
|
sub last_filename { |
146
|
4
|
50
|
|
4
|
0
|
20
|
shift->{MDU_File} || []; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#------------------------------ |
150
|
|
|
|
|
|
|
1; |