summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-10-15 09:19:02 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-10-15 09:19:02 +0000
commit8be5f608f6696ee966fa295d23ecd0c1c2220447 (patch)
tree7ee42dd60ccc2fe510f47a06e71145d7544cafcf
parent7513c55b67d9e188cba73297143ae84a4902129b (diff)
downloadperl-8be5f608f6696ee966fa295d23ecd0c1c2220447.tar.gz
Update MIME::Base64 and Digest::MD5 from the CPAN version.
p4raw-id: //depot/perl@21451
-rw-r--r--ext/Digest/MD5/Changes37
-rw-r--r--ext/Digest/MD5/MD5.pm6
-rw-r--r--ext/Digest/MD5/Makefile.PL1
-rw-r--r--ext/Digest/MD5/t/align.t2
-rw-r--r--ext/Digest/MD5/t/files.t12
-rw-r--r--ext/Digest/MD5/t/utf8.t8
-rw-r--r--ext/MIME/Base64/Base64.pm29
-rw-r--r--ext/MIME/Base64/Base64.xs22
-rw-r--r--ext/MIME/Base64/Changes16
-rw-r--r--ext/MIME/Base64/Makefile.PL2
-rw-r--r--ext/MIME/Base64/QuotedPrint.pm50
-rw-r--r--ext/MIME/Base64/t/unicode.t17
12 files changed, 150 insertions, 52 deletions
diff --git a/ext/Digest/MD5/Changes b/ext/Digest/MD5/Changes
index 3298052985..a6e3dd861d 100644
--- a/ext/Digest/MD5/Changes
+++ b/ext/Digest/MD5/Changes
@@ -1,3 +1,28 @@
+2003-10-09 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.30
+
+ Some tweaks to make the module build on perl-5.004 and
+ perl-5.005 again.
+
+
+
+2003-10-06 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.29
+
+ Another try. Forgot to update the test checksums.
+
+
+
+2003-10-06 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.28
+
+ Fix minor documentation typo.
+
+
+
2003-08-04 Gisle Aas <gisle@ActiveState.com>
Release 2.27
@@ -131,7 +156,7 @@
Release 2.16
Sync up with the bleadperl version:
- - use SvPVbyte() if avaiable
+ - use SvPVbyte() if available
- fixes to make the code 'gcc -Wall'-clean
@@ -140,7 +165,7 @@
Release 2.15
- Avoid exit() in Makefile.PL and bleedperls redefinition of printf
+ Avoid exit() in Makefile.PL and bleadperl redefinition of printf
in the alignment test program.
Patch by Doug MacEachern <dougm@covalent.net>.
@@ -157,7 +182,7 @@
Document the missing padding for the base64 digests.
If both XS bootstrap and locating Digest::Perl::MD5 fails
- reraise the original XS bootstrap exception.
+ re-raise the original XS bootstrap exception.
@@ -400,7 +425,7 @@
$md5->digest will automatically reset now.
Digest::HMAC methods add() and addfile() did not return the
- corret object.
+ correct object.
Added Digest.pm loading module. I am not sure this is a good idea.
@@ -543,7 +568,7 @@ amount of data passed to any single call to the underlying MD5
routines is limited to (2^32 - 1) bytes -- that's 4 gigabytes. I'm
sorry if that's a real problem for you ...
-And finally, a minor complilation warning (unsigned char * used with
+And finally, a minor compilation warning (unsigned char * used with
function having char * prototype) has also been eliminated.
*** 96/04/09 Version 1.6
@@ -565,7 +590,7 @@ examples as to how the routines might be used.
*** 96/03/12 Version 1.5.2
Minor fixes from Christopher J Madsen <madsen@computek.net> to provide
-support for building on OS/2 (and to work arround a perl -w bug).
+support for building on OS/2 (and to work around a perl -w bug).
Remove warning about possible difference between add('foo', 'bar') and
add('foobar'). This is not true (it may have been true in the earliest
diff --git a/ext/Digest/MD5/MD5.pm b/ext/Digest/MD5/MD5.pm
index dc0bc25d46..29a2ab5fb4 100644
--- a/ext/Digest/MD5/MD5.pm
+++ b/ext/Digest/MD5/MD5.pm
@@ -3,7 +3,7 @@ package Digest::MD5;
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
-$VERSION = '2.27'; # $Date: 2003/08/05 06:08:10 $
+$VERSION = '2.30'; # $Date: 2003/10/09 09:26:59 $
require Exporter;
*import = \&Exporter::import;
@@ -104,7 +104,7 @@ characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and
Note that the base64 encoded string returned is not padded to be a
multiple of 4 bytes long. If you want interoperability with other
base64 encoded md5 digests you might want to append the redundant
-string redundant "==" to the result.
+string "==" to the result.
=back
@@ -247,7 +247,7 @@ This is useful when calculating checksum for files:
close(FILE);
print $md5->b64digest, " $file\n";
-Or we can use the builtin addfile method for more efficient reading of
+Or we can use the addfile method for more efficient reading of
the file:
use Digest::MD5;
diff --git a/ext/Digest/MD5/Makefile.PL b/ext/Digest/MD5/Makefile.PL
index 1a91de02dc..b2c974ef07 100644
--- a/ext/Digest/MD5/Makefile.PL
+++ b/ext/Digest/MD5/Makefile.PL
@@ -24,7 +24,6 @@ WriteMakefile(
@extra,
'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
);
-exit;
diff --git a/ext/Digest/MD5/t/align.t b/ext/Digest/MD5/t/align.t
index e9660f3914..90dfe8048e 100644
--- a/ext/Digest/MD5/t/align.t
+++ b/ext/Digest/MD5/t/align.t
@@ -13,7 +13,7 @@ use strict;
use Digest::MD5 qw(md5_hex);
my $str = "\100" x 20;
-substr($str, 0, 1, ""); # chopping off first char makes the string unaligned
+substr($str, 0, 1) = ""; # chopping off first char makes the string unaligned
#use Devel::Peek; Dump($str);
diff --git a/ext/Digest/MD5/t/files.t b/ext/Digest/MD5/t/files.t
index 86327d3fd9..bc4bddc0f9 100644
--- a/ext/Digest/MD5/t/files.t
+++ b/ext/Digest/MD5/t/files.t
@@ -20,26 +20,26 @@ use Digest::MD5 qw(md5 md5_hex md5_base64);
my $EXPECT;
if (ord "A" == 193) { # EBCDIC
$EXPECT = <<EOT;
-4553104c3c951d43043b3520388b8a1e Changes
+e1d7df564fad76d2f0ed628c648d5833 Changes
0565ec21b15c0f23f4c51fb327c8926d README
-36dc7eba19a0fea92baf68bec5adc56a MD5.pm
+4d48606863dbc7fd131c2e7b5eefc8c5 MD5.pm
45e5e6785b47fb922f33b4a74c29a148 MD5.xs
276da0aa4e9a08b7fe09430c9c5690aa rfc1321.txt
EOT
} elsif ("\n" eq "\015") { # MacOS
$EXPECT = <<EOT;
-9ffb101ffaa83f2d04bc5cea6ee0bfb4 Changes
+c780484c87b64e32bd55c6be58b623b4 Changes
6c950a0211a5a28f023bb482037698cd README
-188b5ab345169e90094165dd32dd7f6b MD5.pm
+546c4e62999c9888d7d46732a21c9dff MD5.pm
ca3f8cb317c5d088ed9f97204c6b8cda MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
} else {
# This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
$EXPECT = <<EOT;
-6b0b5e6be6ee9dbbfbb1d77f9a82a87f Changes
+2bdd59aa1e816cd8df05968e70f75cf1 Changes
6c950a0211a5a28f023bb482037698cd README
-188b5ab345169e90094165dd32dd7f6b MD5.pm
+546c4e62999c9888d7d46732a21c9dff MD5.pm
ca3f8cb317c5d088ed9f97204c6b8cda MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
diff --git a/ext/Digest/MD5/t/utf8.t b/ext/Digest/MD5/t/utf8.t
index 83b980a4ec..6cf68b7ae6 100644
--- a/ext/Digest/MD5/t/utf8.t
+++ b/ext/Digest/MD5/t/utf8.t
@@ -1,8 +1,10 @@
#!perl -w
-if ($] < 5.006) {
- print "1..0\n";
- exit;
+BEGIN {
+ if ($] < 5.006) {
+ print "1..0 # Skipped: your perl don't know unicode\n";
+ exit;
+ }
}
print "1..3\n";
diff --git a/ext/MIME/Base64/Base64.pm b/ext/MIME/Base64/Base64.pm
index 26db2091bb..a008c7da45 100644
--- a/ext/MIME/Base64/Base64.pm
+++ b/ext/MIME/Base64/Base64.pm
@@ -1,5 +1,5 @@
#
-# $Id: Base64.pm,v 2.29 2003/05/13 18:22:09 gisle Exp $
+# $Id: Base64.pm,v 2.34 2003/10/09 19:15:42 gisle Exp $
package MIME::Base64;
@@ -33,7 +33,7 @@ The following functions are provided:
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 C<"\n">). The
+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
@@ -49,8 +49,8 @@ Any character not part of the 65-character base64 subset set is
silently ignored. Characters occuring after a '=' padding character
are never decoded.
-If the length of the string to decode (after ignoring
-non-base64 chars) is not a multiple of 4 or padding occurs too early,
+If the length of the string to decode, after ignoring
+non-base64 chars, is not a multiple of 4 or padding occurs too early,
then a warning is generated if perl is running under C<-w>.
=back
@@ -127,6 +127,10 @@ Mulder <hansm@wsinti07.win.tue.nl>
The XS implementation use code from metamail. Copyright 1991 Bell
Communications Research, Inc. (Bellcore)
+=head1 SEE ALSO
+
+L<MIME::QuotedPrint>
+
=cut
use strict;
@@ -137,7 +141,7 @@ require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(encode_base64 decode_base64);
-$VERSION = '2.20';
+$VERSION = '2.21';
eval { bootstrap MIME::Base64 $VERSION; };
if ($@) {
@@ -153,10 +157,20 @@ if ($@) {
# The XS implementation runs about 20 times faster, but the Perl
# code might be more portable, so it is still here.
-use integer;
-
sub old_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;
@@ -180,6 +194,7 @@ sub old_encode_base64 ($;$)
sub old_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
diff --git a/ext/MIME/Base64/Base64.xs b/ext/MIME/Base64/Base64.xs
index 9cbf2b548e..6a36766b4d 100644
--- a/ext/MIME/Base64/Base64.xs
+++ b/ext/MIME/Base64/Base64.xs
@@ -1,4 +1,4 @@
-/* $Id: Base64.xs,v 1.37 2003/05/13 18:20:18 gisle Exp $
+/* $Id: Base64.xs,v 1.38 2003/10/09 11:26:12 gisle Exp $
Copyright 1997-2003 Gisle Aas
@@ -159,7 +159,7 @@ encode_base64(sv,...)
chunk = 0;
}
c1 = *str++;
- c2 = *str++;
+ c2 = len > 1 ? *str++ : '\0';
*r++ = basis_64[c1>>2];
*r++ = basis_64[((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)];
if (len > 2) {
@@ -298,7 +298,7 @@ encode_qp(sv,...)
while (p < end && qp_isplain(*p)) {
p++;
}
- if (*p == '\n' || p == end) {
+ if (p == end || *p == '\n') {
/* whitespace at end of line must be encoded */
while (p > p_beg && (*(p - 1) == '\t' || *(p - 1) == ' '))
p--;
@@ -308,9 +308,9 @@ encode_qp(sv,...)
if (p_len) {
/* output plain text (with line breaks) */
if (eol_len) {
- STRLEN max_last_line = (*p == '\n' || p == end)
+ STRLEN max_last_line = (p == end || *p == '\n')
? MAX_LINE /* .......\n */
- : (*(p + 1) == '\n' || (p + 1) == end)
+ : ((p + 1) == end || *(p + 1) == '\n')
? MAX_LINE - 3 /* ....=XX\n */
: MAX_LINE - 4; /* ...=XX=\n */
while (p_len + linelen > max_last_line) {
@@ -331,13 +331,17 @@ encode_qp(sv,...)
}
}
- if (*p == '\n' && eol_len) {
+ if (p == end) {
+ break;
+ }
+ else if (*p == '\n' && eol_len) {
sv_catpvn(RETVAL, eol, eol_len);
p++;
linelen = 0;
}
- else if (p < end) {
+ else {
/* output escaped char (with line breaks) */
+ assert(p < end)
if (eol_len && linelen > MAX_LINE - 4) {
sv_catpvn(RETVAL, "=", 1);
sv_catpvn(RETVAL, eol, eol_len);
@@ -347,10 +351,6 @@ encode_qp(sv,...)
p++;
linelen += 3;
}
- else {
- assert(p == end);
- break;
- }
/* optimize reallocs a bit */
if (SvLEN(RETVAL) > 80 && SvLEN(RETVAL) - SvCUR(RETVAL) < 3) {
diff --git a/ext/MIME/Base64/Changes b/ext/MIME/Base64/Changes
index 143d31ffcf..c387caab37 100644
--- a/ext/MIME/Base64/Changes
+++ b/ext/MIME/Base64/Changes
@@ -1,3 +1,19 @@
+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
diff --git a/ext/MIME/Base64/Makefile.PL b/ext/MIME/Base64/Makefile.PL
index d863adb18e..7a4e13ec75 100644
--- a/ext/MIME/Base64/Makefile.PL
+++ b/ext/MIME/Base64/Makefile.PL
@@ -1,4 +1,4 @@
-require 5.002;
+require 5.005;
use ExtUtils::MakeMaker;
WriteMakefile(
diff --git a/ext/MIME/Base64/QuotedPrint.pm b/ext/MIME/Base64/QuotedPrint.pm
index 663031fdbb..6988a8da27 100644
--- a/ext/MIME/Base64/QuotedPrint.pm
+++ b/ext/MIME/Base64/QuotedPrint.pm
@@ -1,5 +1,5 @@
#
-# $Id: QuotedPrint.pm,v 2.13 2003/05/13 18:22:09 gisle Exp $
+# $Id: QuotedPrint.pm,v 2.17 2003/10/09 19:04:29 gisle Exp $
package MIME::QuotedPrint;
@@ -34,13 +34,24 @@ The following functions are provided:
=item encode_qp($str, $eol)
This function will return 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 C<"\n">).
+argument.
+
+The second argument is the line ending sequence to use. It is
+optional and defaults to "\n". Every occurence of "\n" will be
+replaced with this string and it will also be 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 external consumption. The string "\r\n" will produce the
+same result on many platforms, but not all.
+
+An $eol of "" special. If passed no "soft line breaks" are introduced
+and any literal "\n" in the original data is encoded as well.
=item decode_qp($str);
This function will return the plain text version of the string given
-as argument. Lines with be "\n" terminated.
+as argument. The lines of the result will be "\n" terminated even it
+the $str argument contains "\r\n" terminated lines.
=back
@@ -52,6 +63,17 @@ call them as:
$encoded = MIME::QuotedPrint::encode($decoded);
$decoded = MIME::QuotedPrint::decode($encoded);
+Perl v5.6 and better allow extended Unicode characters in strings.
+Such strings cannot be encoded directly as the quoted-printable
+encoding is only defined for bytes. The solution is to use the Encode
+module to select the byte encoding you want. For example:
+
+ use MIME::QuotedPrint qw(encode_qp);
+ use Encode qw(encode);
+
+ $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
+ print $encoded;
+
=head1 COPYRIGHT
Copyright 1995-1997,2002-2003 Gisle Aas.
@@ -59,6 +81,10 @@ Copyright 1995-1997,2002-2003 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::Base64>
+
=cut
use strict;
@@ -71,9 +97,7 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(encode_qp decode_qp);
-use Carp qw(croak);
-
-$VERSION = "2.20";
+$VERSION = "2.21";
use MIME::Base64; # try to load XS version of encode_qp
unless (defined &encode_qp) {
@@ -87,13 +111,15 @@ sub old_encode_qp ($;$)
if ($] >= 5.006) {
require bytes;
if (bytes::length($res) > length($res) ||
- ($] >= 5.008 && $res =~ /[^\0-\xFF]/)) {
- croak("The Quoted-Printable encoding is only defined for bytes");
+ ($] >= 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) || length($eol);
+ $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('<')).
@@ -122,12 +148,15 @@ sub old_encode_qp ($;$)
}
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 = "";
@@ -137,6 +166,7 @@ sub old_encode_qp ($;$)
|[^=\n] (?! [^=\n]{0,2} $) # 74 not followed by .?.?\n
| (?! [^=\n]{0,3} $) # 73 not followed by .?.?.?\n
))//xsm;
+ $res =~ s/\n\z/$eol/;
"$brokenlines$res";
}
diff --git a/ext/MIME/Base64/t/unicode.t b/ext/MIME/Base64/t/unicode.t
index 8037440703..b09a328b3c 100644
--- a/ext/MIME/Base64/t/unicode.t
+++ b/ext/MIME/Base64/t/unicode.t
@@ -9,14 +9,25 @@ BEGIN {
}
}
-print "1..1\n";
+print "1..2\n";
require MIME::Base64;
eval {
- MIME::Base64::encode(v300);
+ my $tmp = MIME::Base64::encode(v300);
+ print "# enc: $tmp\n";
};
-
+print "# $@" if $@;
print "not " unless $@;
print "ok 1\n";
+require MIME::QuotedPrint;
+
+eval {
+ my $tmp = MIME::QuotedPrint::encode(v300);
+ print "# enc: $tmp\n";
+};
+print "# $@" if $@;
+print "not " unless $@;
+print "ok 2\n";
+