| 1 | package MIME::Decoder::UU; | ||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 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<MIME::Decoder> 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<MIME::Decoder> | ||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||
| 30 | =head1 AUTHOR | ||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||
| 32 | Eryq (F<eryq@zeegee.com>), ZeeGee Software Inc (F<http://www.zeegee.com>). | ||||||||||||||||||||||||
| 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 | 2 | require 5.002; | |||||||||||||||||||||||
| 44 | 2 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 45 | 2 | ▶ | use MIME::Decoder; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 46 | 2 | ▶ | use MIME::Tools qw(whine); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||
| 48 | 2 | @ISA = qw(MIME::Decoder); | |||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||
| 50 | # The package version, both in 1.23 style *and* usable by MakeMaker: | ||||||||||||||||||||||||
| 51 | 2 | $VERSION = "5.522"; | |||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||
| 54 | #------------------------------ | ||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||
| 56 | # decode_it IN, OUT | ||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||
| 58 | 7 | ▶ | sub decode_it { | ||||||||||||||||||||||
|
Subroutine
decode_it: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||
| 59 | 7 | my ($self, $in, $out) = @_; | |||||||||||||||||||||||
| 60 | 7 | my ($mode, $file); | |||||||||||||||||||||||
| 61 | 7 | my @preamble; | |||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||
| 63 | ### Init: | ||||||||||||||||||||||||
| 64 | 7 | $self->{MDU_Preamble} = \@preamble; | |||||||||||||||||||||||
| 65 | 7 | $self->{MDU_Mode} = undef; | |||||||||||||||||||||||
| 66 | 7 | $self->{MDU_File} = undef; | |||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||
| 68 | ### Find beginning... | ||||||||||||||||||||||||
| 69 | 7 | local $_; | |||||||||||||||||||||||
| 70 | 7 | ▶ | while (defined($_ = $in->getline)) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 71 | 16 | ▶ | if (/^begin(.*)/) { ### found it: now decode it... | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 72 | 5 | my $modefile = $1; | |||||||||||||||||||||||
| 73 | 5 | ▶ | if ($modefile =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 74 | 5 | ($mode, $file) = ($2, $4); | |||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||
| 76 | 5 | last; ### decoded or not, we're done | |||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||
| 78 | 11 | push @preamble, $_; | |||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||
| 80 | 7 | ▶ | die("uu decoding: no begin found\n") if !defined($_); # hit eof! | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||
| 82 | ### Store info: | ||||||||||||||||||||||||
| 83 | 5 | $self->{MDU_Mode} = $mode; | |||||||||||||||||||||||
| 84 | 5 | $self->{MDU_File} = $file; | |||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||
| 86 | ### Decode: | ||||||||||||||||||||||||
| 87 | 5 | ▶ | while (defined($_ = $in->getline)) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 88 | 299 | ▶ | last if /^end/; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 89 | 294 | ▶ | next if /[a-z]/; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 90 | 294 | ▶ | next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 91 | 294 | $out->print(unpack('u', $_)); | |||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||
| 93 | ### chmod oct($mode), $file; # sheeyeah... right... | ||||||||||||||||||||||||
| 94 | 5 | ▶ | whine "file incomplete, no end found\n" if !defined($_); # eof | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 95 | 5 | 1; | |||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||
| 98 | #------------------------------ | ||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||
| 100 | # encode_it IN, OUT | ||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||
| 102 | 1 | ▶ | sub encode_it { | ||||||||||||||||||||||
|
Subroutine
encode_it: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||
| 103 | 1 | my ($self, $in, $out) = @_; | |||||||||||||||||||||||
| 104 | 1 | my $buf = ''; | |||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||
| 106 | 1 | ▶ | my $fname = (($self->head && | ||||||||||||||||||||||
|
Condition40%2/5
$self->head && $self->head->mime_attr('content-disposition.filename') || ''
$self->head and $self->head->mime_attr("content-disposition.filename")
MC/DC0%0/2
$self->head && $self->head->mime_attr('content-disposition.filename') || ''
$self->head
$self->head->mime_attr("content-disposition.filename")
Truth table33%1/3
A and B
A= $self->headB= $self->head->mime_attr("content-disposition.filename")
| |||||||||||||||||||||||||
| 107 | $self->head->mime_attr('content-disposition.filename')) || | ||||||||||||||||||||||||
| 108 | ''); | ||||||||||||||||||||||||
| 109 | 1 | ▶ | my $nl = $MIME::Entity::BOUNDARY_DELIMITER || "\n"; | ||||||||||||||||||||||
|
Condition50%1/2
$MIME::Entity::BOUNDARY_DELIMITER || "\n"
MC/DC0%0/1
$MIME::Entity::BOUNDARY_DELIMITER || "\n"
$MIME::Entity::BOUNDARY_DELIMITER
Truth table50%1/2
A
A= $MIME::Entity::BOUNDARY_DELIMITER
| |||||||||||||||||||||||||
| 110 | 1 | $out->print("begin 644 $fname$nl"); | |||||||||||||||||||||||
| 111 | 1 | ▶ | while ($in->read($buf, 45)) { $out->print(pack('u', $buf)) } | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 112 | 1 | $out->print("end$nl"); | |||||||||||||||||||||||
| 113 | 1 | 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 | 4 | ▶ | sub last_preamble { | ||||||||||||||||||||||
|
Subroutine
last_preamble: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||
| 124 | 4 | my $self = shift; | |||||||||||||||||||||||
| 125 | 4 | ▶ | return $self->{MDU_Preamble} || []; | ||||||||||||||||||||||
|
Condition50%1/2
$self->{'MDU_Preamble'} || []
MC/DC0%0/1
$self->{'MDU_Preamble'} || []
$self->{'MDU_Preamble'}
Truth table50%1/2
A
A= $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 | 4 | ▶ | sub last_mode { | ||||||||||||||||||||||
|
Subroutine
last_mode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||
| 136 | 4 | shift->{MDU_Mode}; | |||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||
| 139 | #------------------------------ | ||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||
| 141 | # last_filename | ||||||||||||||||||||||||
| 142 | # | ||||||||||||||||||||||||
| 143 | # Return the last filename. | ||||||||||||||||||||||||
| 144 | # Gets reset by decode_it(). | ||||||||||||||||||||||||
| 145 | # | ||||||||||||||||||||||||
| 146 | 4 | ▶ | sub last_filename { | ||||||||||||||||||||||
|
Subroutine
last_filename: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||
| 147 | 4 | ▶ | shift->{MDU_File} || []; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||
| 150 | #------------------------------ | ||||||||||||||||||||||||
| 151 | 2 | 1; | |||||||||||||||||||||||