line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Decoder::UU; |
2
|
2
|
|
|
2
|
|
168
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
121
|
|
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
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
46
|
2
|
|
|
2
|
|
12
|
use MIME::Tools qw(whine); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1437
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
@ISA = qw(MIME::Decoder); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# The package version, both in 1.23 style *and* usable by MakeMaker: |
51
|
|
|
|
|
|
|
$VERSION = "5.509"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#------------------------------ |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# decode_it IN, OUT |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
sub decode_it { |
59
|
7
|
|
|
7
|
1
|
10
|
my ($self, $in, $out) = @_; |
60
|
7
|
|
|
|
|
9
|
my ($mode, $file); |
61
|
0
|
|
|
|
|
0
|
my @preamble; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
### Init: |
64
|
7
|
|
|
|
|
18
|
$self->{MDU_Preamble} = \@preamble; |
65
|
7
|
|
|
|
|
13
|
$self->{MDU_Mode} = undef; |
66
|
7
|
|
|
|
|
11
|
$self->{MDU_File} = undef; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
### Find beginning... |
69
|
7
|
|
|
|
|
9
|
local $_; |
70
|
7
|
|
|
|
|
219
|
while (defined($_ = $in->getline)) { |
71
|
16
|
100
|
|
|
|
360
|
if (/^begin(.*)/) { ### found it: now decode it... |
72
|
5
|
|
|
|
|
11
|
my $modefile = $1; |
73
|
5
|
50
|
|
|
|
31
|
if ($modefile =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/) { |
74
|
5
|
|
|
|
|
16
|
($mode, $file) = ($2, $4); |
75
|
|
|
|
|
|
|
} |
76
|
5
|
|
|
|
|
12
|
last; ### decoded or not, we're done |
77
|
|
|
|
|
|
|
} |
78
|
11
|
|
|
|
|
142
|
push @preamble, $_; |
79
|
|
|
|
|
|
|
} |
80
|
7
|
100
|
|
|
|
75
|
die("uu decoding: no begin found\n") if !defined($_); # hit eof! |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
### Store info: |
83
|
5
|
|
|
|
|
7
|
$self->{MDU_Mode} = $mode; |
84
|
5
|
|
|
|
|
9
|
$self->{MDU_File} = $file; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
### Decode: |
87
|
5
|
|
|
|
|
86
|
while (defined($_ = $in->getline)) { |
88
|
299
|
100
|
|
|
|
11241
|
last if /^end/; |
89
|
294
|
50
|
|
|
|
565
|
next if /[a-z]/; |
90
|
294
|
50
|
|
|
|
680
|
next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); |
91
|
294
|
|
|
|
|
953
|
$out->print(unpack('u', $_)); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
### chmod oct($mode), $file; # sheeyeah... right... |
94
|
5
|
50
|
|
|
|
42
|
whine "file incomplete, no end found\n" if !defined($_); # eof |
95
|
5
|
|
|
|
|
26
|
1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#------------------------------ |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# encode_it IN, OUT |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
sub encode_it { |
103
|
1
|
|
|
1
|
1
|
4
|
my ($self, $in, $out) = @_; |
104
|
1
|
|
|
|
|
2
|
my $buf = ''; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
50
|
|
|
11
|
my $fname = (($self->head && |
107
|
|
|
|
|
|
|
$self->head->mime_attr('content-disposition.filename')) || |
108
|
|
|
|
|
|
|
''); |
109
|
1
|
|
50
|
|
|
5
|
my $nl = $MIME::Entity::BOUNDARY_DELIMITER || "\n"; |
110
|
1
|
|
|
|
|
7
|
$out->print("begin 644 $fname$nl"); |
111
|
1
|
|
|
|
|
12
|
while ($in->read($buf, 45)) { $out->print(pack('u', $buf)) } |
|
68
|
|
|
|
|
657
|
|
112
|
1
|
|
|
|
|
14
|
$out->print("end$nl"); |
113
|
1
|
|
|
|
|
9
|
1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#------------------------------ |
117
|
|
|
|
|
|
|
# |
118
|
|
|
|
|
|
|
# last_preamble |
119
|
|
|
|
|
|
|
# |
120
|
|
|
|
|
|
|
# Return the last preamble as ref to array of lines. |
121
|
|
|
|
|
|
|
# Gets reset by decode_it(). |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
sub last_preamble { |
124
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
125
|
4
|
|
50
|
|
|
12
|
return $self->{MDU_Preamble} || []; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#------------------------------ |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# last_mode |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
# Return the last mode. |
133
|
|
|
|
|
|
|
# Gets reset to undef by decode_it(). |
134
|
|
|
|
|
|
|
# |
135
|
|
|
|
|
|
|
sub last_mode { |
136
|
4
|
|
|
4
|
0
|
9
|
shift->{MDU_Mode}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#------------------------------ |
140
|
|
|
|
|
|
|
# |
141
|
|
|
|
|
|
|
# last_filename |
142
|
|
|
|
|
|
|
# |
143
|
|
|
|
|
|
|
# Return the last filename. |
144
|
|
|
|
|
|
|
# Gets reset by decode_it(). |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
sub last_filename { |
147
|
4
|
50
|
|
4
|
0
|
12
|
shift->{MDU_File} || []; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#------------------------------ |
151
|
|
|
|
|
|
|
1; |