#
-# $Id: Base64.pm,v 2.28 2003/05/13 16:21:25 gisle Exp $
+# $Id: Base64.pm,v 2.29 2003/05/13 18:22:09 gisle Exp $
package MIME::Base64;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(encode_base64 decode_base64);
-$VERSION = '2.19';
+$VERSION = '2.20';
eval { bootstrap MIME::Base64 $VERSION; };
if ($@) {
-/* $Id: Base64.xs,v 1.36 2003/05/13 16:21:25 gisle Exp $
+/* $Id: Base64.xs,v 1.37 2003/05/13 18:20:18 gisle Exp $
Copyright 1997-2003 Gisle Aas
}
whitespace = 0;
}
- if (*str == '=' && (str + 2) < end && isxdigit(str[1]) && isxdigit(str[2])) {
- char buf[3];
- str++;
- buf[0] = *str++;
- buf[1] = *str++;
- buf[2] = '\0';
- *r++ = (char)strtol(buf, 0, 16);
- }
- else if (*str == '=' && (str + 1) < end && str[1] == '\n') {
- str += 2;
+ if (*str == '=') {
+ if ((str + 2) < end && isxdigit(str[1]) && isxdigit(str[2])) {
+ char buf[3];
+ str++;
+ buf[0] = *str++;
+ buf[1] = *str++;
+ buf[2] = '\0';
+ *r++ = (char)strtol(buf, 0, 16);
+ }
+ else {
+ /* look for soft line break */
+ char *p = str + 1;
+ while (p < end && (*p == ' ' || *p == '\t'))
+ p++;
+ if (p < end && *p == '\n')
+ str = p + 1;
+ else if ((p + 1) < end && *p == '\r' && *(p + 1) == '\n')
+ str = p + 2;
+ else
+ *r++ = *str++; /* give up */
+ }
}
- else if (*str == '=' && (str + 2) < end && str[1] == '\r' && str[2] == '\n') {
- str += 3;
+ else {
+ *r++ = *str++;
}
- else {
- *r++ = *str++;
- }
}
}
if (whitespace) {
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.
#
-# $Id: QuotedPrint.pm,v 2.12 2003/05/13 16:21:25 gisle Exp $
+# $Id: QuotedPrint.pm,v 2.13 2003/05/13 18:22:09 gisle Exp $
package MIME::QuotedPrint;
use Carp qw(croak);
-$VERSION = "2.19";
+$VERSION = "2.20";
use MIME::Base64; # try to load XS version of encode_qp
unless (defined &encode_qp) {
["foo\t \n \t", "foo=09=20\n=20=09"],
);
-$notests = @tests + 7;
+$notests = @tests + 13;
print "1..$notests\n";
$testno = 0;
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 "not " unless encode_qp("$x70!2345$x70\n", "***") eq "$x70!2345=***$x70***";
$testno++; print "ok $testno\n";