#
-# $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;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(encode_base64 decode_base64);
-$VERSION = '2.16';
+$VERSION = '2.19';
eval { bootstrap MIME::Base64 $VERSION; };
if ($@) {
-/* $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
#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[] =
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;
} 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]);*/
}
}
- if (*p == '\n') {
+ if (*p == '\n' && eol_len) {
sv_catpvn(RETVAL, eol, eol_len);
p++;
linelen = 0;
}
}
}
+ if (whitespace) {
+ while (whitespace < str) {
+ *r++ = *whitespace++;
+ }
+ }
*r = '\0';
SvCUR_set(RETVAL, r - SvPVX(RETVAL));
+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
#
-# $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;
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) {
# 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;
"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";