From 2c634edc13b5b5cb4d6fa1bb56a8859a91a81976 Mon Sep 17 00:00:00 2001 From: Gisle Aas Date: Tue, 13 May 2003 02:59:50 -0700 Subject: [PATCH] Sync up MIME-Base64 to latest on CPAN Message-ID: p4raw-id: //depot/perl@19517 --- ext/MIME/Base64/Base64.pm | 4 ++-- ext/MIME/Base64/Base64.xs | 20 ++++++++++++++++---- ext/MIME/Base64/Changes | 37 +++++++++++++++++++++++++++++++++++++ ext/MIME/Base64/QuotedPrint.pm | 4 ++-- ext/MIME/Base64/t/quoted-print.t | 21 ++++++++++++++++++++- 5 files changed, 77 insertions(+), 9 deletions(-) diff --git a/ext/MIME/Base64/Base64.pm b/ext/MIME/Base64/Base64.pm index 378adf5..ebf94ba 100644 --- a/ext/MIME/Base64/Base64.pm +++ b/ext/MIME/Base64/Base64.pm @@ -1,5 +1,5 @@ # -# $Id: Base64.pm,v 2.25 2003/01/05 08:01:33 gisle Exp $ +# $Id: Base64.pm,v 2.28 2003/05/13 16:21:25 gisle Exp $ package MIME::Base64; @@ -137,7 +137,7 @@ require DynaLoader; @ISA = qw(Exporter DynaLoader); @EXPORT = qw(encode_base64 decode_base64); -$VERSION = '2.16'; +$VERSION = '2.19'; eval { bootstrap MIME::Base64 $VERSION; }; if ($@) { diff --git a/ext/MIME/Base64/Base64.xs b/ext/MIME/Base64/Base64.xs index 6f855fb..d540f11 100644 --- a/ext/MIME/Base64/Base64.xs +++ b/ext/MIME/Base64/Base64.xs @@ -1,4 +1,4 @@ -/* $Id: Base64.xs,v 1.32 2003/01/05 07:49:07 gisle Exp $ +/* $Id: Base64.xs,v 1.36 2003/05/13 16:21:25 gisle Exp $ Copyright 1997-2003 Gisle Aas @@ -46,6 +46,13 @@ extern "C" { #define PL_dowarn dowarn #endif +#ifdef G_WARN_ON + #define DOWARN (PL_dowarn & G_WARN_ON) +#else + #define DOWARN PL_dowarn +#endif + + #define MAX_LINE 76 /* size of encoded lines */ static char basis_64[] = @@ -209,7 +216,7 @@ decode_base64(sv) if (str == end) { if (i < 4) { - if (i && PL_dowarn) + if (i && DOWARN) warn("Premature end of base64 data"); if (i < 2) goto thats_it; if (i == 2) c[2] = EQ; @@ -220,7 +227,7 @@ decode_base64(sv) } while (i < 4); if (c[0] == EQ || c[1] == EQ) { - if (PL_dowarn) warn("Premature padding of base64 data"); + if (DOWARN) warn("Premature padding of base64 data"); break; } /* printf("c0=%d,c1=%d,c2=%d,c3=%d\n", c[0],c[1],c[2],c[3]);*/ @@ -324,7 +331,7 @@ encode_qp(sv,...) } } - if (*p == '\n') { + if (*p == '\n' && eol_len) { sv_catpvn(RETVAL, eol, eol_len); p++; linelen = 0; @@ -410,6 +417,11 @@ decode_qp(sv) } } } + if (whitespace) { + while (whitespace < str) { + *r++ = *whitespace++; + } + } *r = '\0'; SvCUR_set(RETVAL, r - SvPVX(RETVAL)); diff --git a/ext/MIME/Base64/Changes b/ext/MIME/Base64/Changes index fab3cca..24c31f0 100644 --- a/ext/MIME/Base64/Changes +++ b/ext/MIME/Base64/Changes @@ -1,3 +1,40 @@ +2003-05-13 Gisle Aas + + 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 . + + + +2003-03-09 Gisle Aas + + Release 2.18 + + Fix up INSTALLDIRS for perl-5.8 and newer. + + + +2003-03-09 Gisle Aas + + 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 Release 2.16 diff --git a/ext/MIME/Base64/QuotedPrint.pm b/ext/MIME/Base64/QuotedPrint.pm index 778cdab..08d3468 100644 --- a/ext/MIME/Base64/QuotedPrint.pm +++ b/ext/MIME/Base64/QuotedPrint.pm @@ -1,5 +1,5 @@ # -# $Id: QuotedPrint.pm,v 2.11 2003/01/05 08:01:33 gisle Exp $ +# $Id: QuotedPrint.pm,v 2.12 2003/05/13 16:21:25 gisle Exp $ package MIME::QuotedPrint; @@ -73,7 +73,7 @@ require Exporter; use Carp qw(croak); -$VERSION = "2.16"; +$VERSION = "2.19"; use MIME::Base64; # try to load XS version of encode_qp unless (defined &encode_qp) { diff --git a/ext/MIME/Base64/t/quoted-print.t b/ext/MIME/Base64/t/quoted-print.t index 6642724..884bebb 100644 --- a/ext/MIME/Base64/t/quoted-print.t +++ b/ext/MIME/Base64/t/quoted-print.t @@ -85,9 +85,13 @@ y. -- H. L. Mencken"], # 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 + 3; +$notests = @tests + 7; print "1..$notests\n"; $testno = 0; @@ -127,5 +131,20 @@ 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"; + +# Test with with alternative line break +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"; -- 2.7.4