Change 18883 by [EMAIL PROTECTED] on 2003/03/10 18:54:19

        Integrate:
        [ 18642]
        Integrate MIME::Base64 2.16 from CPAN. (Do we really want the
        utility scripts?)

Affected files ...

... //depot/maint-5.8/perl/MANIFEST#32 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/Base64.pm#3 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/Changes#3 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/Makefile.PL#3 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/QuotedPrint.pm#3 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/decode-base64#1 branch
... //depot/maint-5.8/perl/ext/MIME/Base64/decode-qp#1 branch
... //depot/maint-5.8/perl/ext/MIME/Base64/encode-base64#1 branch
... //depot/maint-5.8/perl/ext/MIME/Base64/encode-qp#1 branch
... //depot/maint-5.8/perl/ext/MIME/Base64/t/base64.t#2 integrate
... //depot/maint-5.8/perl/ext/MIME/Base64/t/quoted-print.t#3 integrate

Differences ...

==== //depot/maint-5.8/perl/MANIFEST#32 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#31~18866~     Sun Mar  9 05:59:01 2003
+++ perl/MANIFEST       Mon Mar 10 10:54:19 2003
@@ -506,6 +506,10 @@
 ext/MIME/Base64/Changes                MIME::Base64 extension
 ext/MIME/Base64/Makefile.PL    MIME::Base64 extension
 ext/MIME/Base64/QuotedPrint.pm MIME::Base64 extension
+ext/MIME/Base64/encode-qp      MIME::Base64 utility
+ext/MIME/Base64/decode-qp      MIME::Base64 utility
+ext/MIME/Base64/encode-base64  MIME::Base64 utility
+ext/MIME/Base64/decode-base64  MIME::Base64 utility
 ext/MIME/Base64/t/base64.t     See whether MIME::Base64 works
 ext/MIME/Base64/t/quoted-print.t       See whether MIME::QuotedPrint works
 ext/MIME/Base64/t/unicode.t    See whether MIME::Base64 works

==== //depot/maint-5.8/perl/ext/MIME/Base64/Base64.pm#3 (text) ====
Index: perl/ext/MIME/Base64/Base64.pm
--- perl/ext/MIME/Base64/Base64.pm#2~18503~     Thu Jan 16 15:29:57 2003
+++ perl/ext/MIME/Base64/Base64.pm      Mon Mar 10 10:54:19 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Base64.pm,v 2.19 2002/12/28 06:32:37 gisle Exp $
+# $Id: Base64.pm,v 2.25 2003/01/05 08:01:33 gisle Exp $
 
 package MIME::Base64;
 
@@ -27,7 +27,9 @@
 
 =over 4
 
-=item encode_base64($str, [$eol])
+=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
@@ -112,7 +114,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 1995-1999, 2001 Gisle Aas.
+Copyright 1995-1999, 2001-2003 Gisle Aas.
 
 This library is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.
@@ -135,7 +137,7 @@
 @ISA = qw(Exporter DynaLoader);
 @EXPORT = qw(encode_base64 decode_base64);
 
-$VERSION = '2.13';
+$VERSION = '2.16';
 
 eval { bootstrap MIME::Base64 $VERSION; };
 if ($@) {
@@ -187,6 +189,7 @@
     }
     $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) . $_,

==== //depot/maint-5.8/perl/ext/MIME/Base64/Changes#3 (text) ====
Index: perl/ext/MIME/Base64/Changes
--- perl/ext/MIME/Base64/Changes#2~18503~       Thu Jan 16 15:29:57 2003
+++ perl/ext/MIME/Base64/Changes        Mon Mar 10 10:54:19 2003
@@ -1,4 +1,50 @@
-2002-02-27   Gisle Aas <[EMAIL PROTECTED]>
+2003-01-05   Gisle Aas <[EMAIL PROTECTED]>
+
+   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 <[EMAIL PROTECTED]>
+
+   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 <[EMAIL PROTECTED]>
+
+   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 <[EMAIL PROTECTED]>
 
    Release 2.13
 

==== //depot/maint-5.8/perl/ext/MIME/Base64/Makefile.PL#3 (text) ====
Index: perl/ext/MIME/Base64/Makefile.PL
--- perl/ext/MIME/Base64/Makefile.PL#2~18700~   Thu Feb 13 06:55:54 2003
+++ perl/ext/MIME/Base64/Makefile.PL    Mon Mar 10 10:54:19 2003
@@ -3,7 +3,7 @@
 
 WriteMakefile(
     NAME        => 'MIME::Base64',
-    MAN3PODS    => {},  # Pods will be built by installman.
     VERSION_FROM => 'Base64.pm',
+    EXE_FILES    => [qw(encode-base64 decode-base64 encode-qp decode-qp)],
     dist         => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
 );

==== //depot/maint-5.8/perl/ext/MIME/Base64/QuotedPrint.pm#3 (text) ====
Index: perl/ext/MIME/Base64/QuotedPrint.pm
--- perl/ext/MIME/Base64/QuotedPrint.pm#2~18503~        Thu Jan 16 15:29:57 2003
+++ perl/ext/MIME/Base64/QuotedPrint.pm Mon Mar 10 10:54:19 2003
@@ -1,5 +1,5 @@
 #
-# $Id: QuotedPrint.pm,v 2.4 2002/12/28 05:50:05 gisle Exp $
+# $Id: QuotedPrint.pm,v 2.11 2003/01/05 08:01:33 gisle Exp $
 
 package MIME::QuotedPrint;
 
@@ -31,17 +31,16 @@
 
 =item encode_qp($str)
 
-This function will return an encoded version of the string given as
-argument.
+=item encode_qp($str, $eol)
 
-Note that encode_qp() does not change newlines C<"\n"> to the CRLF
-sequence even though this might be considered the right thing to do
-(RFC 2045 (Q-P Rule #4)).
+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">).
 
 =item decode_qp($str);
 
 This function will return the plain text version of the string given
-as argument.
+as argument.  Lines with be "\n" terminated.
 
 =back
 
@@ -55,7 +54,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 1995-1997 Gisle Aas.
+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.
@@ -74,9 +73,15 @@
 
 use Carp qw(croak);
 
-$VERSION = sprintf("%d.%02d", q$Revision: 2.4 $ =~ /(\d+)\.(\d+)/);
+$VERSION = "2.16";
 
-sub encode_qp ($)
+use MIME::Base64;  # try to load XS version of encode_qp
+unless (defined &encode_qp) {
+    *encode_qp = \&old_encode_qp;
+    *decode_qp = \&old_decode_qp;
+}
+
+sub old_encode_qp ($;$)
 {
     my $res = shift;
     if ($] >= 5.006) {
@@ -87,6 +92,9 @@
        }
     }
 
+    my $eol = shift;
+    $eol = "\n" unless defined($eol) || length($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
@@ -123,7 +131,7 @@
     # 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=\n"
+    $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
@@ -134,11 +142,12 @@
 }
 
 
-sub decode_qp ($)
+sub old_decode_qp ($)
 {
     my $res = shift;
-    $res =~ s/[ \t]+?(\r?\n)/$1/g;  # rule #3 (trailing space must be deleted)
-    $res =~ s/=\r?\n//g;            # rule #5 (soft line breaks)
+    $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;

==== //depot/maint-5.8/perl/ext/MIME/Base64/decode-base64#1 (xtext) ====
Index: perl/ext/MIME/Base64/decode-base64
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/MIME/Base64/decode-base64  Mon Mar 10 10:54:19 2003
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use MIME::Base64 qw(decode_base64);
+
+while (<>) {
+    print decode_base64($_);
+}
+

==== //depot/maint-5.8/perl/ext/MIME/Base64/decode-qp#1 (xtext) ====
Index: perl/ext/MIME/Base64/decode-qp
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/MIME/Base64/decode-qp      Mon Mar 10 10:54:19 2003
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use MIME::QuotedPrint qw(decode_qp);
+
+while (<>) {
+    print decode_qp($_);
+}
+

==== //depot/maint-5.8/perl/ext/MIME/Base64/encode-base64#1 (xtext) ====
Index: perl/ext/MIME/Base64/encode-base64
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/MIME/Base64/encode-base64  Mon Mar 10 10:54:19 2003
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+use MIME::Base64 qw(encode_base64);
+
+my $buf = "";
+while (<>) {
+    $buf .= $_;
+    if (length($buf) >= 57) {
+       print encode_base64(substr($buf, 0, int(length($buf) / 57) * 57, ""));
+    }
+}
+
+print encode_base64($buf);

==== //depot/maint-5.8/perl/ext/MIME/Base64/encode-qp#1 (xtext) ====
Index: perl/ext/MIME/Base64/encode-qp
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/MIME/Base64/encode-qp      Mon Mar 10 10:54:19 2003
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use MIME::QuotedPrint qw(encode_qp);
+
+while (<>) {
+    print encode_qp($_);
+}
+

==== //depot/maint-5.8/perl/ext/MIME/Base64/t/base64.t#2 (text) ====
Index: perl/ext/MIME/Base64/t/base64.t
--- perl/ext/MIME/Base64/t/base64.t#1~17645~    Fri Jul 19 12:29:57 2002
+++ perl/ext/MIME/Base64/t/base64.t     Mon Mar 10 10:54:19 2003
@@ -337,15 +337,15 @@
        }
 
        if (ord('A') != 193) { # perl versions broken on EBCDIC
-       # Try the old Perl versions too
-       if ($encoded ne MIME::Base64::old_encode_base64($plain, '')) {
-           print "old_encode_base64 give different result.\n";
-           print "not ";
-        }
-       if ($plain ne MIME::Base64::old_decode_base64($encoded)) {
-           print "old_decode_base64 give different result.\n";
-           print "not ";
-        }
+           # Try the old Perl versions too
+           if ($encoded ne MIME::Base64::old_encode_base64($plain, '')) {
+               print "old_encode_base64 give different result.\n";
+               print "not ";
+           }
+           if ($plain ne MIME::Base64::old_decode_base64($encoded)) {
+               print "old_decode_base64 give different result.\n";
+               print "not ";
+           }
        }
                
        print "ok $testno\n";

==== //depot/maint-5.8/perl/ext/MIME/Base64/t/quoted-print.t#3 (text) ====
Index: perl/ext/MIME/Base64/t/quoted-print.t
--- perl/ext/MIME/Base64/t/quoted-print.t#2~18503~      Thu Jan 16 15:29:57 2003
+++ perl/ext/MIME/Base64/t/quoted-print.t       Mon Mar 10 10:54:19 2003
@@ -25,8 +25,8 @@
    ["test  \ntest\n\t \t \n" => "test=20=20\ntest\n=09=20=09=20\n"],
 
    # "=" is special an should be decoded
-   ["=\n" => "=3D\n"],
-   ["\0\xff" => "=00=FF"],
+   ["=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." =>
@@ -57,20 +57,34 @@
    ["$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===xxxx" => "$x70=3D=\n=3D=3Dxxxx"],
-   ["$x70!===xxx" => "$x70!=3D=\n=3D=3Dxxx"],
-   ["$x70!!===xx" => "$x70!!=3D=\n=3D=3Dxx"],
-   ["$x70!!!===x" => "$x70!!!=\n=3D=3D=3Dx"],
-   #                            ^
-   #                    70123456|
-   #                           max
-   #                        line width
+   ["$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"],
 );
 
 $notests = @tests + 3;
@@ -110,8 +124,8 @@
 
 # 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\r\n\r\nfoo \r\nfoo \r\n\r\n";
+                                "foo\n\nfoo \nfoo \n\n";
 $testno++; print "ok $testno\n";
 
-print "not " if $] >= 5.006 && (eval 'encode_qp("XXX \x{100}")' || $@ !~ /^The 
Quoted-Printable encoding is only defined for bytes/);
+print "not " if $] >= 5.006 && (eval 'encode_qp("XXX \x{100}")' || !$@);
 $testno++; print "ok $testno\n";
End of Patch.

Reply via email to