diff options
| author | fukachan <fukachan> | 2005-05-28 11:58:56 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2005-05-28 11:58:56 +0000 |
| commit | 9b6fd07dd3d6378862787bd7ff6994a1fa50d4df (patch) | |
| tree | 76e444dc1e7c3b839cab9b11cdc8c250e0a2098f /cpan/dist | |
| parent | 8764c2fcf4bd8b42e5e208222faae403d9b4d661 (diff) | |
| download | fml8-9b6fd07dd3d6378862787bd7ff6994a1fa50d4df.tar.gz fml8-9b6fd07dd3d6378862787bd7ff6994a1fa50d4df.tar.bz2 fml8-9b6fd07dd3d6378862787bd7ff6994a1fa50d4df.zip | |
Initial revision
Diffstat (limited to 'cpan/dist')
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/Changes | 286 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/MANIFEST | 9 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/Makefile.PL | 8 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/README | 27 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/lib/MIME/Base64/Perl.pm | 152 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/lib/MIME/QuotedPrint/Perl.pm | 181 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/t/base64.t | 371 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/t/quoted-print.t | 162 | ||||
| -rw-r--r-- | cpan/dist/MIME-Base64-Perl/t/unicode.t | 28 |
9 files changed, 1224 insertions, 0 deletions
diff --git a/cpan/dist/MIME-Base64-Perl/Changes b/cpan/dist/MIME-Base64-Perl/Changes new file mode 100644 index 00000000..a06a2a1f --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/Changes @@ -0,0 +1,286 @@ +2004-01-14 Gisle Aas <gisle@ActiveState.com> + + Release 1.00 + + Based on the pure Perl implementation of the base64 and + quoted-printable encoder/decoder from MIME-Base64-2.23. + + Made it work with perl-5.004. + + Change entries after this one refers to the MIME-Base64 + package. + + + +2004-01-08 Gisle Aas <gisle@ActiveState.com> + + Release 2.23 + + Documentation fixes by Paul Croome <Paul.Croome@softwareag.com>. + + + +2004-01-08 Gisle Aas <gisle@ActiveState.com> + + Release 2.22 + + Fix 'gcc -Wall' complaints. + + + +2003-10-09 Gisle Aas <gisle@ActiveState.com> + + Release 2.21 + + Documentation tweaks. + + Don't rely on SvEND(sv) == '\0' as discussed in the perl5-porters + mailing list thread that starts with + http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-10/msg00258.html + + Should now pass test suite even without XS support. + + Perl v5.005 or better is now required. + + + +2003-05-13 Gisle Aas <gisle@ActiveState.com> + + Release 2.20 + + decode_qp() recognize soft whitespace when there is whitespace + between the '=' and the '\n'. + + + +2003-05-13 Gisle Aas <gisle@ActiveState.com> + + Release 2.19 + + decode_qp() did eat up all trailing whitespace in the string decoded. + Only whitespace in front of "\n" should go. + + Win32 fix for t/warn.t by Reini Urban <rurban@x-ray.at>. + + + +2003-03-09 Gisle Aas <gisle@ActiveState.com> + + Release 2.18 + + Fix up INSTALLDIRS for perl-5.8 and newer. + + + +2003-03-09 Gisle Aas <gisle@ActiveState.com> + + Release 2.17 + + Make it reliable to disable base64 decoding warnings by + resetting $^W in recent perls. Would really like to be + able to do real lexical warnings but the current mechanism + does not seems suitable for XS code. + + Passing "" as $eol to encode_qp() disable soft line + breaks as well. + + Sync up with changes in bleadperl: + - safer patchlevel.h include + - bad cast + + + +2003-01-05 Gisle Aas <gisle@ActiveState.com> + + Release 2.16 + + Fixed the encode_qp() line breaking code. It sometimes + made lines longer than 76 chars and it could even get into + an infinite loop on certain inputs. + + + +2003-01-03 Gisle Aas <gisle@ActiveState.com> + + Release 2.15 + + Fixed the XS based decode_qp() for strings where a =XX + sequence was followed by digits. + + Faster encode_qp() for long strings with lots of chars + that need escaping. + + The old_decode_base64() function introduced in 2.13 + was returning undef for empty input on olders perls. + This problem has been fixed. + + + +2003-01-01 Gisle Aas <gisle@ActiveState.com> + + Release 2.14 + + MIME::QuotedPrint functions now also implemented using XS + which make them faster. 2-3 times faster when encoding line by + line and as much as 200 times faster on long binary input. There + is probably some breakage on non-ASCII systems from this. + + The encode_qp() function now takes an $eol argument in the + same way as encode_base64() does. + + Slight change in behaviour: the decode_qp() function now turns + \r\n terminated lines into \n terminated lines. This makes is + more likely that encode_qp(decode_qp()) round-trip properly. + + Included {en,de}code-{base64,qp} utility scripts. + + + +2002-12-27 Gisle Aas <gisle@ActiveState.com> + + Release 2.13 + + Sync up with bleadperl: + - Documentation update + - EBCDIC support + - Whitespace tweaks + - Improved Unicode support + - Test suite tweaks + + Improved version of the old_{en,de}code_base64 functions + contributed by Paul Szabo <psz@maths.usyd.edu.au>. + + + +2001-02-23 Gisle Aas <gisle@ActiveState.com> + + Release 2.12 + + Speed up pure perl base64 encoder/decoder by using join/map instead + of while loop. Contributed by Arno Beckmann <arno@gmx.de> + + Doc update contributed by Jerrad Pierce <belg4mit@CALLOWAY.MIT.EDU> + + Downgrade UTF8 strings before starting to encode. + + + +1999-02-27 Gisle Aas <gisle@aas.no> + + Release 2.11 + + Fixed bogus "Premature end of base64 data" warning. Bug spotted + by Dwayne Jacques Fontenot. + + Workaround for Redhat shipping trial releases of perl. + + + +1998-12-18 Gisle Aas <aas@sn.no> + + Release 2.10 + + A tweak that should make compilation with some old perl5.00[23] + perls better. + + A cast that make some compilers more happy. + + + +1998-11-13 Gisle Aas <aas@sn.no> + + Release 2.09 + + The 2.08 release did not compile with perl5.005_53, because + all simple globals now need to be prefixed with "PL_". + + + +1998-10-22 Gisle Aas <aas@sn.no> + + Release 2.08 + + Found another tweak to speed up decode_base64() with another 3%. + + Improved MIME::Base64 documentation a little. + + + +1998-10-21 Gisle Aas <aas@sn.no> + + Release 2.07 + + Faster and smarter C implementation of the decode_base64() + function. The new decode_base64() was 25% faster when tested + on Linux, i586, gcc -O2. + + + +1998-07-15 Gisle Aas <aas@sn.no> + + Release 2.06 + + The decode_base64() implemented in pure perl will only carp + (not croak) if length of data to decode is not a multiple 4. This + actually made 'make test' fail after 'rm Base64.xs'. + + + +1998-01-27 Gisle Aas <aas@sn.no> + + Release 2.05 + + The decode_base64() would previously allocate a too short buffer for the + result string when the trailing "==" padding was missing in the string to + be decoded. + + The encode_base64() now allocate one byte less space in the result + strings returned. + + + +1997-12-02 Gisle Aas <aas@sn.no> + + Release 2.04 + + Documentation expanded a bit. + + + +1997-07-10 Gisle Aas <aas@sn.no> + + Release 2.03 + + Decode_base64() doesn't croak on premature ended data any more. + A warning is generated instead if running under -w. + + + +1997-06-27 Gisle Aas <aas@sn.no> + + Release 2.02 + + QuotedPrint fix by Roderick Schertler <roderick@argon.org>: + + - Long lines were not broken unless they're at the beginning + of the text + + - Lines near but not over 76 chars were broken when they + shouldn't be + + + +1997-06-13 Gisle Aas <aas@sn.no> + + Release 2.01 + + Base64.xs: Avoid type convertion warnings with some compilers + + Minor documentation updates + + + +1997-04-24 Gisle Aas <aas@sn.no> + + Release 2.00, based on libwww-perl-5.08. + diff --git a/cpan/dist/MIME-Base64-Perl/MANIFEST b/cpan/dist/MIME-Base64-Perl/MANIFEST new file mode 100644 index 00000000..f5be2319 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/MANIFEST @@ -0,0 +1,9 @@ +Changes +MANIFEST +Makefile.PL +README +t/base64.t +t/quoted-print.t +t/unicode.t +lib/MIME/Base64/Perl.pm +lib/MIME/QuotedPrint/Perl.pm diff --git a/cpan/dist/MIME-Base64-Perl/Makefile.PL b/cpan/dist/MIME-Base64-Perl/Makefile.PL new file mode 100644 index 00000000..c05c6082 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/Makefile.PL @@ -0,0 +1,8 @@ +require 5.004; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'MIME::Base64::Perl', + VERSION_FROM => 'lib/MIME/Base64/Perl.pm', + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, +); diff --git a/cpan/dist/MIME-Base64-Perl/README b/cpan/dist/MIME-Base64-Perl/README new file mode 100644 index 00000000..01340614 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/README @@ -0,0 +1,27 @@ +This package contains a base64 encoder/decoder and a quoted-printable +encoder/decoder. These encoding methods are specified in RFC 2045 - +MIME (Multipurpose Internet Mail Extensions). + +The base64 encoding is designed to represent arbitrary sequences of +octets in a form that need not be humanly readable. A 65-character +subset ([A-Za-z0-9+/=]) of US-ASCII is used, enabling 6 bits to be +represented per printable character. + +The quoted-printable encoding is intended to represent data that +largely consists of bytes that correspond to printable characters in +the ASCII character set. Each non-printable character is represented by +a triplet consisting of the character "=" followed by two hexadecimal +digits. + +In order to install and use this package you will need Perl version +5.004 or better. Installation as usual: + + perl Makefile.PL + make + make test + make install + +Copyright 1995-1999,2001-2004 Gisle Aas <gisle@ActiveState.com> + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. diff --git a/cpan/dist/MIME-Base64-Perl/lib/MIME/Base64/Perl.pm b/cpan/dist/MIME-Base64-Perl/lib/MIME/Base64/Perl.pm new file mode 100644 index 00000000..34dac89e --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/lib/MIME/Base64/Perl.pm @@ -0,0 +1,152 @@ +package MIME::Base64::Perl; + +# $Id: Perl.pm,v 1.2 2004/01/14 12:52:44 gisle Exp $ + +use strict; +use vars qw(@ISA @EXPORT $VERSION); + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(encode_base64 decode_base64); + +$VERSION = '1.00'; + +sub encode_base64 ($;$) +{ + if ($] >= 5.006) { + require bytes; + if (bytes::length($_[0]) > length($_[0]) || + ($] >= 5.008 && $_[0] =~ /[^\0-\xFF]/)) + { + require Carp; + Carp::croak("The Base64 encoding is only defined for bytes"); + } + } + + use integer; + + my $eol = $_[1]; + $eol = "\n" unless defined $eol; + + my $res = pack("u", $_[0]); + # Remove first character of each line, remove newlines + $res =~ s/^.//mg; + $res =~ s/\n//g; + + $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs + # fix padding at the end + my $padding = (3 - length($_[0]) % 3) % 3; + $res =~ s/.{$padding}$/'=' x $padding/e if $padding; + # break encoded string into lines of no more than 76 characters each + if (length $eol) { + $res =~ s/(.{1,76})/$1$eol/g; + } + return $res; +} + + +sub decode_base64 ($) +{ + local($^W) = 0; # unpack("u",...) gives bogus warning in 5.00[123] + use integer; + + my $str = shift; + $str =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars + if (length($str) % 4) { + require Carp; + Carp::carp("Length of base64 data not a multiple of 4") + } + $str =~ s/=+$//; # remove padding + $str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format + return "" unless length $str; + + ## I guess this could be written as + #return unpack("u", join('', map( chr(32 + length($_)*3/4) . $_, + # $str =~ /(.{1,60})/gs) ) ); + ## but I do not like that... + my $uustr = ''; + my ($i, $l); + $l = length($str) - 60; + for ($i = 0; $i <= $l; $i += 60) { + $uustr .= "M" . substr($str, $i, 60); + } + $str = substr($str, $i); + # and any leftover chars + if ($str ne "") { + $uustr .= chr(32 + length($str)*3/4) . $str; + } + return unpack ("u", $uustr); +} + +1; + +__END__ + +=head1 NAME + +MIME::Base64::Perl - Encoding and decoding of base64 strings + +=head1 SYNOPSIS + + use MIME::Base64::Perl; + + $encoded = encode_base64('Aladdin:open sesame'); + $decoded = decode_base64($encoded); + +=head1 DESCRIPTION + +This module provide the same interface as C<MIME::Base64>, but these +functions are implemented in pure perl. + +This module provides functions to encode and decode strings into and from the +base64 encoding specified in RFC 2045 - I<MIME (Multipurpose Internet +Mail Extensions)>. The base64 encoding is designed to represent +arbitrary sequences of octets in a form that need not be humanly +readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used, +enabling 6 bits to be represented per printable character. + +The following functions are provided: + +=over 4 + +=item encode_base64($str) + +=item encode_base64($str, $eol); + +Encode data by calling the encode_base64() function. The first +argument is the string to encode. The second argument is the +line-ending sequence to use. It is optional and defaults to "\n". The +returned encoded string is broken into lines of no more than 76 +characters each and it will end with $eol unless it is empty. Pass an +empty string as second argument if you do not want the encoded string +to be broken into lines. + +=item decode_base64($str) + +Decode a base64 string by calling the decode_base64() function. This +function takes a single argument which is the string to decode and +returns the decoded data. + +Any character not part of the 65-character base64 subset is +silently ignored. Characters occurring after a '=' padding character +are never decoded. + +=back + +=head1 COPYRIGHT + +Copyright 1995-1999, 2001-2004 Gisle Aas. + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +Distantly based on LWP::Base64 written by Martijn Koster +<m.koster@nexor.co.uk> and Joerg Reichelt <j.reichelt@nexor.co.uk> and +code posted to comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl> by Hans +Mulder <hansm@wsinti07.win.tue.nl> + +=head1 SEE ALSO + +L<MIME::Base64>, L<MIME::QuotedPrint::Perl> + +=cut diff --git a/cpan/dist/MIME-Base64-Perl/lib/MIME/QuotedPrint/Perl.pm b/cpan/dist/MIME-Base64-Perl/lib/MIME/QuotedPrint/Perl.pm new file mode 100644 index 00000000..a5bf6767 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/lib/MIME/QuotedPrint/Perl.pm @@ -0,0 +1,181 @@ + +package MIME::QuotedPrint::Perl; + +# $Id: Perl.pm,v 1.2 2004/01/14 12:52:44 gisle Exp $ + +use strict; +use vars qw(@ISA @EXPORT $VERSION); +if (ord('A') == 193) { # on EBCDIC machines we need translation help + require Encode; +} + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(encode_qp decode_qp); + +$VERSION = "1.00"; + +my $RE_Z = "\\z"; +$RE_Z = "\$" if $] < 5.005; + +sub encode_qp ($;$) +{ + my $res = shift; + if ($] >= 5.006) { + require bytes; + if (bytes::length($res) > length($res) || + ($] >= 5.008 && $res =~ /[^\0-\xFF]/)) + { + require Carp; + Carp::croak("The Quoted-Printable encoding is only defined for bytes"); + } + } + + my $eol = shift; + $eol = "\n" unless defined $eol; + + # Do not mention ranges such as $res =~ s/([^ \t\n!-<>-~])/sprintf("=%02X", ord($1))/eg; + # since that will not even compile on an EBCDIC machine (where ord('!') > ord('<')). + if (ord('A') == 193) { # EBCDIC style machine + if (ord('[') == 173) { + $res =~ s/([^ \t\n!"#\$%&'()*+,\-.\/0-9:;<>?\@A-Z[\\\]^_`a-z{|}~])/sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('cp1047',$1))))/eg; # rule #2,#3 + $res =~ s/([ \t]+)$/ + join('', map { sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('cp1047',$_)))) } + split('', $1) + )/egm; # rule #3 (encode whitespace at eol) + } + elsif (ord('[') == 187) { + $res =~ s/([^ \t\n!"#\$%&'()*+,\-.\/0-9:;<>?\@A-Z[\\\]^_`a-z{|}~])/sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('posix-bc',$1))))/eg; # rule #2,#3 + $res =~ s/([ \t]+)$/ + join('', map { sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('posix-bc',$_)))) } + split('', $1) + )/egm; # rule #3 (encode whitespace at eol) + } + elsif (ord('[') == 186) { + $res =~ s/([^ \t\n!"#\$%&'()*+,\-.\/0-9:;<>?\@A-Z[\\\]^_`a-z{|}~])/sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('cp37',$1))))/eg; # rule #2,#3 + $res =~ s/([ \t]+)$/ + join('', map { sprintf("=%02X", ord(Encode::encode('iso-8859-1',Encode::decode('cp37',$_)))) } + split('', $1) + )/egm; # rule #3 (encode whitespace at eol) + } + } + else { # ASCII style machine + $res =~ s/([^ \t\n!"#\$%&'()*+,\-.\/0-9:;<>?\@A-Z[\\\]^_`a-z{|}~])/sprintf("=%02X", ord($1))/eg; # rule #2,#3 + $res =~ s/\n/=0A/g unless length($eol); + $res =~ s/([ \t]+)$/ + join('', map { sprintf("=%02X", ord($_)) } + split('', $1) + )/egm; # rule #3 (encode whitespace at eol) + } + + return $res unless length($eol); + + # rule #5 (lines must be shorter than 76 chars, but we are not allowed + # to break =XX escapes. This makes things complicated :-( ) + my $brokenlines = ""; + $brokenlines .= "$1=$eol" + while $res =~ s/(.*?^[^\n]{73} (?: + [^=\n]{2} (?! [^=\n]{0,1} $) # 75 not followed by .?\n + |[^=\n] (?! [^=\n]{0,2} $) # 74 not followed by .?.?\n + | (?! [^=\n]{0,3} $) # 73 not followed by .?.?.?\n + ))//xsm; + $res =~ s/\n$RE_Z/$eol/o; + + "$brokenlines$res"; +} + + +sub decode_qp ($) +{ + my $res = shift; + $res =~ s/\r\n/\n/g; # normalize newlines + $res =~ s/[ \t]+\n/\n/g; # rule #3 (trailing space must be deleted) + $res =~ s/=\n//g; # rule #5 (soft line breaks) + if (ord('A') == 193) { # EBCDIC style machine + if (ord('[') == 173) { + $res =~ s/=([\da-fA-F]{2})/Encode::encode('cp1047',Encode::decode('iso-8859-1',pack("C", hex($1))))/ge; + } + elsif (ord('[') == 187) { + $res =~ s/=([\da-fA-F]{2})/Encode::encode('posix-bc',Encode::decode('iso-8859-1',pack("C", hex($1))))/ge; + } + elsif (ord('[') == 186) { + $res =~ s/=([\da-fA-F]{2})/Encode::encode('cp37',Encode::decode('iso-8859-1',pack("C", hex($1))))/ge; + } + } + else { # ASCII style machine + $res =~ s/=([\da-fA-F]{2})/pack("C", hex($1))/ge; + } + $res; +} + +1; + +__END__ + +=head1 NAME + +MIME::QuotedPrint::Perl - Encoding and decoding of quoted-printable strings + +=head1 SYNOPSIS + + use MIME::QuotedPrint::Perl; + + $encoded = encode_qp($decoded); + $decoded = decode_qp($encoded); + +=head1 DESCRIPTION + +This module provide the same interface as C<MIME::QuotedPrint>, but these +functions are implemented in pure perl. + +This module provides functions to encode and decode strings into and from the +quoted-printable encoding specified in RFC 2045 - I<MIME (Multipurpose +Internet Mail Extensions)>. The quoted-printable encoding is intended +to represent data that largely consists of bytes that correspond to +printable characters in the ASCII character set. Each non-printable +character (as defined by English Americans) is represented by a +triplet consisting of the character "=" followed by two hexadecimal +digits. + +The following functions are provided: + +=over 4 + +=item encode_qp($str) + +=item encode_qp($str, $eol) + +This function returns an encoded version of the string given as +argument. + +The second argument is the line-ending sequence to use. It is +optional and defaults to "\n". Every occurrence of "\n" is +replaced with this string, and it is also used for additional +"soft line breaks" to ensure that no line is longer than 76 +characters. You might want to pass it as "\015\012" to produce data +suitable for external consumption. The string "\r\n" produces the +same result on many platforms, but not all. + +An $eol of "" (the empty string) is special. In this case, no "soft line breaks" are introduced +and any literal "\n" in the original data is encoded as well. + +=item decode_qp($str); + +This function returns the plain text version of the string given +as argument. The lines of the result are "\n" terminated, even if +the $str argument contains "\r\n" terminated lines. + +=back + +=head1 COPYRIGHT + +Copyright 1995-1997,2002-2004 Gisle Aas. + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=head1 SEE ALSO + +L<MIME::QuotedPrint>, L<MIME::Base64::Perl> + +=cut diff --git a/cpan/dist/MIME-Base64-Perl/t/base64.t b/cpan/dist/MIME-Base64-Perl/t/base64.t new file mode 100644 index 00000000..2fc8a0e3 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/t/base64.t @@ -0,0 +1,371 @@ +use strict; +use MIME::Base64::Perl; + +print "1..283\n"; + +print "# Testing MIME::Base64::Perl-", $MIME::Base64::Perl::VERSION, "\n"; + +BEGIN { + if (ord('A') == 0x41) { + *ASCII = sub { return $_[0] }; + } + else { + require Encode; + *ASCII = sub { Encode::encode('ascii',$_[0]) }; + } +} + +my $testno = 1; +# instead of "for my $test (...)" , which is my preference. +# Not sure which perl version has started supporting. MIME::Base64 +# was supposed to work with very old perl5, right? +my $test; + +encodeTest(); +decodeTest(); + +# This used to generate a warning +print "not " unless decode_base64(encode_base64("foo")) eq "foo"; +print "ok ", $testno++, "\n"; + +sub encodeTest +{ + print "# encode test\n"; + + my @encode_tests = ( + # All values + ["\000" => "AA=="], + ["\001" => "AQ=="], + ["\002" => "Ag=="], + ["\003" => "Aw=="], + ["\004" => "BA=="], + ["\005" => "BQ=="], + ["\006" => "Bg=="], + ["\007" => "Bw=="], + ["\010" => "CA=="], + ["\011" => "CQ=="], + ["\012" => "Cg=="], + ["\013" => "Cw=="], + ["\014" => "DA=="], + ["\015" => "DQ=="], + ["\016" => "Dg=="], + ["\017" => "Dw=="], + ["\020" => "EA=="], + ["\021" => "EQ=="], + ["\022" => "Eg=="], + ["\023" => "Ew=="], + ["\024" => "FA=="], + ["\025" => "FQ=="], + ["\026" => "Fg=="], + ["\027" => "Fw=="], + ["\030" => "GA=="], + ["\031" => "GQ=="], + ["\032" => "Gg=="], + ["\033" => "Gw=="], + ["\034" => "HA=="], + ["\035" => "HQ=="], + ["\036" => "Hg=="], + ["\037" => "Hw=="], + ["\040" => "IA=="], + ["\041" => "IQ=="], + ["\042" => "Ig=="], + ["\043" => "Iw=="], + ["\044" => "JA=="], + ["\045" => "JQ=="], + ["\046" => "Jg=="], + ["\047" => "Jw=="], + ["\050" => "KA=="], + ["\051" => "KQ=="], + ["\052" => "Kg=="], + ["\053" => "Kw=="], + ["\054" => "LA=="], + ["\055" => "LQ=="], + ["\056" => "Lg=="], + ["\057" => "Lw=="], + ["\060" => "MA=="], + ["\061" => "MQ=="], + ["\062" => "Mg=="], + ["\063" => "Mw=="], + ["\064" => "NA=="], + ["\065" => "NQ=="], + ["\066" => "Ng=="], + ["\067" => "Nw=="], + ["\070" => "OA=="], + ["\071" => "OQ=="], + ["\072" => "Og=="], + ["\073" => "Ow=="], + ["\074" => "PA=="], + ["\075" => "PQ=="], + ["\076" => "Pg=="], + ["\077" => "Pw=="], + ["\100" => "QA=="], + ["\101" => "QQ=="], + ["\102" => "Qg=="], + ["\103" => "Qw=="], + ["\104" => "RA=="], + ["\105" => "RQ=="], + ["\106" => "Rg=="], + ["\107" => "Rw=="], + ["\110" => "SA=="], + ["\111" => "SQ=="], + ["\112" => "Sg=="], + ["\113" => "Sw=="], + ["\114" => "TA=="], + ["\115" => "TQ=="], + ["\116" => "Tg=="], + ["\117" => "Tw=="], + ["\120" => "UA=="], + ["\121" => "UQ=="], + ["\122" => "Ug=="], + ["\123" => "Uw=="], + ["\124" => "VA=="], + ["\125" => "VQ=="], + ["\126" => "Vg=="], + ["\127" => "Vw=="], + ["\130" => "WA=="], + ["\131" => "WQ=="], + ["\132" => "Wg=="], + ["\133" => "Ww=="], + ["\134" => "XA=="], + ["\135" => "XQ=="], + ["\136" => "Xg=="], + ["\137" => "Xw=="], + ["\140" => "YA=="], + ["\141" => "YQ=="], + ["\142" => "Yg=="], + ["\143" => "Yw=="], + ["\144" => "ZA=="], + ["\145" => "ZQ=="], + ["\146" => "Zg=="], + ["\147" => "Zw=="], + ["\150" => "aA=="], + ["\151" => "aQ=="], + ["\152" => "ag=="], + ["\153" => "aw=="], + ["\154" => "bA=="], + ["\155" => "bQ=="], + ["\156" => "bg=="], + ["\157" => "bw=="], + ["\160" => "cA=="], + ["\161" => "cQ=="], + ["\162" => "cg=="], + ["\163" => "cw=="], + ["\164" => "dA=="], + ["\165" => "dQ=="], + ["\166" => "dg=="], + ["\167" => "dw=="], + ["\170" => "eA=="], + ["\171" => "eQ=="], + ["\172" => "eg=="], + ["\173" => "ew=="], + ["\174" => "fA=="], + ["\175" => "fQ=="], + ["\176" => "fg=="], + ["\177" => "fw=="], + ["\200" => "gA=="], + ["\201" => "gQ=="], + ["\202" => "gg=="], + ["\203" => "gw=="], + ["\204" => "hA=="], + ["\205" => "hQ=="], + ["\206" => "hg=="], + ["\207" => "hw=="], + ["\210" => "iA=="], + ["\211" => "iQ=="], + ["\212" => "ig=="], + ["\213" => "iw=="], + ["\214" => "jA=="], + ["\215" => "jQ=="], + ["\216" => "jg=="], + ["\217" => "jw=="], + ["\220" => "kA=="], + ["\221" => "kQ=="], + ["\222" => "kg=="], + ["\223" => "kw=="], + ["\224" => "lA=="], + ["\225" => "lQ=="], + ["\226" => "lg=="], + ["\227" => "lw=="], + ["\230" => "mA=="], + ["\231" => "mQ=="], + ["\232" => "mg=="], + ["\233" => "mw=="], + ["\234" => "nA=="], + ["\235" => "nQ=="], + ["\236" => "ng=="], + ["\237" => "nw=="], + ["\240" => "oA=="], + ["\241" => "oQ=="], + ["\242" => "og=="], + ["\243" => "ow=="], + ["\244" => "pA=="], + ["\245" => "pQ=="], + ["\246" => "pg=="], + ["\247" => "pw=="], + ["\250" => "qA=="], + ["\251" => "qQ=="], + ["\252" => "qg=="], + ["\253" => "qw=="], + ["\254" => "rA=="], + ["\255" => "rQ=="], + ["\256" => "rg=="], + ["\257" => "rw=="], + ["\260" => "sA=="], + ["\261" => "sQ=="], + ["\262" => "sg=="], + ["\263" => "sw=="], + ["\264" => "tA=="], + ["\265" => "tQ=="], + ["\266" => "tg=="], + ["\267" => "tw=="], + ["\270" => "uA=="], + ["\271" => "uQ=="], + ["\272" => "ug=="], + ["\273" => "uw=="], + ["\274" => "vA=="], + ["\275" => "vQ=="], + ["\276" => "vg=="], + ["\277" => "vw=="], + ["\300" => "wA=="], + ["\301" => "wQ=="], + ["\302" => "wg=="], + ["\303" => "ww=="], + ["\304" => "xA=="], + ["\305" => "xQ=="], + ["\306" => "xg=="], + ["\307" => "xw=="], + ["\310" => "yA=="], + ["\311" => "yQ=="], + ["\312" => "yg=="], + ["\313" => "yw=="], + ["\314" => "zA=="], + ["\315" => "zQ=="], + ["\316" => "zg=="], + ["\317" => "zw=="], + ["\320" => "0A=="], + ["\321" => "0Q=="], + ["\322" => "0g=="], + ["\323" => "0w=="], + ["\324" => "1A=="], + ["\325" => "1Q=="], + ["\326" => "1g=="], + ["\327" => "1w=="], + ["\330" => "2A=="], + ["\331" => "2Q=="], + ["\332" => "2g=="], + ["\333" => "2w=="], + ["\334" => "3A=="], + ["\335" => "3Q=="], + ["\336" => "3g=="], + ["\337" => "3w=="], + ["\340" => "4A=="], + ["\341" => "4Q=="], + ["\342" => "4g=="], + ["\343" => "4w=="], + ["\344" => "5A=="], + ["\345" => "5Q=="], + ["\346" => "5g=="], + ["\347" => "5w=="], + ["\350" => "6A=="], + ["\351" => "6Q=="], + ["\352" => "6g=="], + ["\353" => "6w=="], + ["\354" => "7A=="], + ["\355" => "7Q=="], + ["\356" => "7g=="], + ["\357" => "7w=="], + ["\360" => "8A=="], + ["\361" => "8Q=="], + ["\362" => "8g=="], + ["\363" => "8w=="], + ["\364" => "9A=="], + ["\365" => "9Q=="], + ["\366" => "9g=="], + ["\367" => "9w=="], + ["\370" => "+A=="], + ["\371" => "+Q=="], + ["\372" => "+g=="], + ["\373" => "+w=="], + ["\374" => "/A=="], + ["\375" => "/Q=="], + ["\376" => "/g=="], + ["\377" => "/w=="], + + ["\000\377" => "AP8="], + ["\377\000" => "/wA="], + ["\000\000\000" => "AAAA"], + + ['' => ''], + [ASCII('a') => 'YQ=='], + [ASCII('aa') => 'YWE='], + [ASCII('aaa') => 'YWFh'], + + [ASCII('aaa') => 'YWFh'], + [ASCII('aaa') => 'YWFh'], + [ASCII('aaa') => 'YWFh'], + + + # from HTTP spec + [ASCII('Aladdin:open sesame') => 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='], + + [ASCII('a') x 100 => 'YWFh' x 33 . 'YQ=='], + + [ASCII('Multipurpose Internet Mail Extensions: The Base64 Content-Transfer-Encoding is designed to represent sequences of octets in a form that is not humanly readable. ') + => "TXVsdGlwdXJwb3NlIEludGVybmV0IE1haWwgRXh0ZW5zaW9uczogVGhlIEJhc2U2NCBDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nIGlzIGRlc2lnbmVkIHRvIHJlcHJlc2VudCBzZXF1ZW5jZXMgb2Ygb2N0ZXRzIGluIGEgZm9ybSB0aGF0IGlzIG5vdCBodW1hbmx5IHJlYWRhYmxlLiA="], + + ); + + for $test (@encode_tests) { + my($plain, $expected) = ($$test[0], $$test[1]); + + my $encoded = encode_base64($plain, ''); + if ($encoded ne $expected) { + print "test $testno ($plain): expected $expected, got $encoded\n"; + print "not "; + } + my $decoded = decode_base64($encoded); + if ($decoded ne $plain) { + print "test $testno ($encoded): expected $plain, got $decoded\n"; + print "not "; + } + + print "ok $testno\n"; + $testno++; + } +} + +sub decodeTest +{ + print "# decode test\n"; + + local $SIG{__WARN__} = sub { print $_[0] }; # avoid warnings on stderr + + my @decode_tests = ( + ['YWE=' => ASCII('aa')], + [' YWE=' => ASCII('aa')], + ['Y WE=' => ASCII('aa')], + ['YWE= ' => ASCII('aa')], + ["Y\nW\r\nE=" => ASCII('aa')], + + # These will generate some warnings + ['YWE=====' => ASCII('aa')], # extra padding + ['YWE' => ASCII('aa')], # missing padding + ['YWFh====' => ASCII('aaa')], + ['YQ' => ASCII('a')], + ['Y' => ''], + ['x==' => ''], + ['' => ''], + [undef() => ''], + ); + + for $test (@decode_tests) { + my($encoded, $expected) = ($$test[0], $$test[1]); + + my $decoded = decode_base64($encoded); + if ($decoded ne $expected) { + die "test $testno ($encoded): expected $expected, got $decoded\n"; + } + print "ok $testno\n"; + $testno++; + } +} diff --git a/cpan/dist/MIME-Base64-Perl/t/quoted-print.t b/cpan/dist/MIME-Base64-Perl/t/quoted-print.t new file mode 100644 index 00000000..a69cd63b --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/t/quoted-print.t @@ -0,0 +1,162 @@ +use MIME::QuotedPrint::Perl; + +$x70 = "x" x 70; + +@tests = + ( + # plain ascii should not be encoded + ["quoted printable" => + "quoted printable"], + + # 8-bit chars should be encoded + ["v\xe5re kj\xe6re norske tegn b\xf8r \xe6res" => + "v=E5re kj=E6re norske tegn b=F8r =E6res"], + + # trailing space should be encoded + [" " => "=20=20"], + ["\tt\t" => "\tt=09"], + ["test \ntest\n\t \t \n" => "test=20=20\ntest\n=09=20=09=20\n"], + + # "=" is special an should be decoded + ["=30\n" => "=3D30\n"], + ["\0\xff0" => "=00=FF0"], + + # Very long lines should be broken (not more than 76 chars + ["The Quoted-Printable encoding is intended to represent data that largly consists of octets that correspond to printable characters in the ASCII character set." => + "The Quoted-Printable encoding is intended to represent data that largly con= +sists of octets that correspond to printable characters in the ASCII charac= +ter set." + ], + + # Long lines after short lines were broken through 2.01. + ["short line +In America, any boy may become president and I suppose that's just one of the risks he takes. -- Adlai Stevenson" => + "short line +In America, any boy may become president and I suppose that's just one of t= +he risks he takes. -- Adlai Stevenson"], + + # My (roderick@argon.org) first crack at fixing that bug failed for + # multiple long lines. + ["College football is a game which would be much more interesting if the faculty played instead of the students, and even more interesting if the +trustees played. There would be a great increase in broken arms, legs, and necks, and simultaneously an appreciable diminution in the loss to humanity. -- H. L. Mencken" => + "College football is a game which would be much more interesting if the facu= +lty played instead of the students, and even more interesting if the +trustees played. There would be a great increase in broken arms, legs, and= + necks, and simultaneously an appreciable diminution in the loss to humanit= +y. -- H. L. Mencken"], + + # Don't break a line that's near but not over 76 chars. + ["$x70!23" => "$x70!23"], + ["$x70!234" => "$x70!234"], + ["$x70!2345" => "$x70!2345"], + ["$x70!23456" => "$x70!23456"], + ["$x70!234567" => "$x70!2345=\n67"], + ["$x70!23456=" => "$x70!2345=\n6=3D"], + ["$x70!23\n" => "$x70!23\n"], + ["$x70!234\n" => "$x70!234\n"], + ["$x70!2345\n" => "$x70!2345\n"], + ["$x70!23456\n" => "$x70!23456\n"], + ["$x70!234567\n" => "$x70!2345=\n67\n"], + ["$x70!23456=\n" => "$x70!2345=\n6=3D\n"], + + # Not allowed to break =XX escapes using soft line break + ["$x70===xxxxx" => "$x70=3D=\n=3D=3Dxxxxx"], + ["$x70!===xxxx" => "$x70!=3D=\n=3D=3Dxxxx"], + ["$x70!2===xxx" => "$x70!2=3D=\n=3D=3Dxxx"], + ["$x70!23===xx" => "$x70!23=\n=3D=3D=3Dxx"], + ["$x70!234===x" => "$x70!234=\n=3D=3D=3Dx"], + ["$x70!2=\n" => "$x70!2=3D\n"], + ["$x70!23=\n" => "$x70!23=\n=3D\n"], + ["$x70!234=\n" => "$x70!234=\n=3D\n"], + ["$x70!2345=\n" => "$x70!2345=\n=3D\n"], + ["$x70!23456=\n" => "$x70!2345=\n6=3D\n"], + # ^ + # 70123456| + # max + # line width + + # some extra special cases we have had problems with + ["$x70!2=x=x" => "$x70!2=3D=\nx=3Dx"], + ["$x70!2345$x70!2345$x70!23456\n", "$x70!2345=\n$x70!2345=\n$x70!23456\n"], + + # trailing whitespace + ["foo \t ", "foo=20=09=20"], + ["foo\t \n \t", "foo=09=20\n=20=09"], +); + +$notests = @tests + 13; +print "1..$notests\n"; + +$testno = 0; +for (@tests) { + $testno++; + ($plain, $encoded) = @$_; + if (ord('A') == 193) { # EBCDIC 8 bit chars are different + if ($testno == 2) { $plain =~ s/\xe5/\x47/; $plain =~ s/\xe6/\x9c/g; $plain =~ s/\xf8/\x70/; } + if ($testno == 7) { $plain =~ s/\xff/\xdf/; } + } + $x = encode_qp($plain); + if ($x ne $encoded) { + print "Encode test failed\n"; + print "Got: '$x'\n"; + print "Expected: '$encoded'\n"; + print "not ok $testno\n"; + next; + } + $x = decode_qp($encoded); + if ($x ne $plain) { + print "Decode test failed\n"; + print "Got: '$x'\n"; + print "Expected: '$plain'\n"; + print "not ok $testno\n"; + next; + } + print "ok $testno\n"; +} + +# Some extra testing for a case that was wrong until libwww-perl-5.09 +print "not " unless decode_qp("foo \n\nfoo =\n\nfoo=20\n\n") eq + "foo\n\nfoo \nfoo \n\n"; +$testno++; print "ok $testno\n"; + +# Same test but with "\r\n" terminated lines +print "not " unless decode_qp("foo \r\n\r\nfoo =\r\n\r\nfoo=20\r\n\r\n") eq + "foo\n\nfoo \nfoo \n\n"; +$testno++; print "ok $testno\n"; + +# Trailing whitespace +print "not " unless decode_qp("foo ") eq "foo "; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo \n") eq "foo\n"; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo = \t\x20\nbar\t\x20\n") eq "foo bar\n"; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo = \t\x20\r\nbar\t\x20\r\n") eq "foo bar\n"; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo = \t\x20\n") eq "foo "; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo = \t\x20\r\n") eq "foo "; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo = \t\x20y\r\n") eq "foo = \t\x20y\n"; +$testno++; print "ok $testno\n"; + +print "not " unless decode_qp("foo =xy\n") eq "foo =xy\n"; +$testno++; print "ok $testno\n"; + +# Test with with alternative line break +print encode_qp("$x70!2345$x70\n", "***"), "\n"; +print "not " unless encode_qp("$x70!2345$x70\n", "***") eq "$x70!2345=***$x70***"; +$testno++; print "ok $testno\n"; + +# Test with no line breaks +print "not " unless encode_qp("$x70!2345$x70\n", "") eq "$x70!2345$x70=0A"; +$testno++; print "ok $testno\n"; + +print "not " if $] >= 5.006 && (eval 'encode_qp("XXX \x{100}")' || !$@); +$testno++; print "ok $testno\n"; diff --git a/cpan/dist/MIME-Base64-Perl/t/unicode.t b/cpan/dist/MIME-Base64-Perl/t/unicode.t new file mode 100644 index 00000000..028de706 --- /dev/null +++ b/cpan/dist/MIME-Base64-Perl/t/unicode.t @@ -0,0 +1,28 @@ +BEGIN { + unless ($] >= 5.006) { + print "1..0\n"; + exit(0); + } +} + +print "1..2\n"; + +require MIME::Base64::Perl; + +eval { + my $tmp = MIME::Base64::Perl::encode_base64(v300); + print "# enc: $tmp\n"; +}; +print "# $@" if $@; +print "not " unless $@; +print "ok 1\n"; + +require MIME::QuotedPrint::Perl; + +eval { + my $tmp = MIME::QuotedPrint::Perl::encode_qp(v300); + print "# enc: $tmp\n"; +}; +print "# $@" if $@; +print "not " unless $@; +print "ok 2\n"; |
