From: Gisle Aas <gisle@aas.no>
Date: Tue, 2 Feb 2010 22:22:15 +0000 (+0100)
Subject: Update to MIME-Base64 3.09
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e58db16ffcf34442d0ba4b645757884324e35c2;p=p5sagit%2Fp5-mst-13.2.git

Update to MIME-Base64 3.09

Fixes issue where the Quoted-Printable encoder would sometimes output
lines that were 77 characters long.  The max line length should be 76.
---

diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index b9bc394..b71c123 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -995,11 +995,11 @@ use File::Glob qw(:case);
     'MIME::Base64' =>
 	{
 	'MAINTAINER'	=> 'gaas',
-	'DISTRIBUTION'	=> 'GAAS/MIME-Base64-3.08.tar.gz',
+	'DISTRIBUTION'	=> 'GAAS/MIME-Base64-3.09.tar.gz',
 	'FILES'		=> q[cpan/MIME-Base64],
 	'EXCLUDED'	=> [ qw{ t/bad-sv.t }, ],
 	'CPAN'		=> 1,
-	'UPSTREAM'	=> undef,
+	'UPSTREAM'	=> 'cpan',
 	},
 
     'Module::Build' =>
diff --git a/cpan/MIME-Base64/Base64.pm b/cpan/MIME-Base64/Base64.pm
index 6c076d1..2bcd585 100644
--- a/cpan/MIME-Base64/Base64.pm
+++ b/cpan/MIME-Base64/Base64.pm
@@ -7,7 +7,7 @@ require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(encode_base64 decode_base64);
 
-$VERSION = '3.08';
+$VERSION = '3.09';
 
 require XSLoader;
 XSLoader::load('MIME::Base64', $VERSION);
diff --git a/cpan/MIME-Base64/Base64.xs b/cpan/MIME-Base64/Base64.xs
index 1740a16..279aad9 100644
--- a/cpan/MIME-Base64/Base64.xs
+++ b/cpan/MIME-Base64/Base64.xs
@@ -1,4 +1,4 @@
-/* $Id$
+/*
 
 Copyright 1997-2004 Gisle Aas
 
@@ -119,7 +119,7 @@ encode_base64(sv,...)
 	PREINIT:
 	char *str;     /* string to encode */
 	SSize_t len;   /* length of the string */
-	char *eol;     /* the end-of-line sequence to use */
+	const char*eol;/* the end-of-line sequence to use */
 	STRLEN eollen; /* length of the EOL sequence */
 	char *r;       /* result string */
 	STRLEN rlen;   /* length of result string */
@@ -157,8 +157,8 @@ encode_base64(sv,...)
 	/* encode */
 	for (chunk=0; len > 0; len -= 3, chunk++) {
 	    if (chunk == (MAX_LINE/4)) {
-		char *c = eol;
-		char *e = eol + eollen;
+		const char *c = eol;
+		const char *e = eol + eollen;
 		while (c < e)
 		    *r++ = *c++;
 		chunk = 0;
@@ -181,8 +181,8 @@ encode_base64(sv,...)
 	}
 	if (rlen) {
 	    /* append eol to the result string */
-	    char *c = eol;
-	    char *e = eol + eollen;
+	    const char *c = eol;
+	    const char *e = eol + eollen;
 	    while (c < e)
 		*r++ = *c++;
 	}
@@ -270,7 +270,7 @@ encode_qp(sv,...)
 	PROTOTYPE: $;$$
 
 	PREINIT:
-	char *eol;
+	const char *eol;
 	STRLEN eol_len;
 	int binary;
 	STRLEN sv_len;
@@ -320,15 +320,8 @@ encode_qp(sv,...)
 	    if (p_len) {
 	        /* output plain text (with line breaks) */
 	        if (eol_len) {
-		    STRLEN max_last_line = (p == end || *p == '\n')
-					      ? MAX_LINE         /* .......\n */
-					      : ((p + 1) == end || *(p + 1) == '\n')
-	                                        ? MAX_LINE - 3   /* ....=XX\n */
-	                                        : MAX_LINE - 4;  /* ...=XX=\n */
-		    while (p_len + linelen > max_last_line) {
+		    while (p_len > MAX_LINE - 1 - linelen) {
 			STRLEN len = MAX_LINE - 1 - linelen;
-			if (len > p_len)
-			    len = p_len;
 			sv_catpvn(RETVAL, p_beg, len);
 			p_beg += len;
 			p_len -= len;
@@ -347,14 +340,21 @@ encode_qp(sv,...)
 		break;
             }
 	    else if (*p == '\n' && eol_len && !binary) {
-	        sv_catpvn(RETVAL, eol, eol_len);
-	        p++;
+		if (linelen == 1 && SvCUR(RETVAL) > eol_len + 1 && SvEND(RETVAL)[-eol_len - 2] == '=') {
+		    /* fixup useless soft linebreak */
+		    SvEND(RETVAL)[-eol_len - 2] = SvEND(RETVAL)[-1];
+		    SvCUR_set(RETVAL, SvCUR(RETVAL) - 1);
+		}
+		else {
+		    sv_catpvn(RETVAL, eol, eol_len);
+		}
+		p++;
 		linelen = 0;
 	    }
 	    else {
 		/* output escaped char (with line breaks) */
 	        assert(p < end);
-		if (eol_len && linelen > MAX_LINE - 4) {
+		if (eol_len && linelen > MAX_LINE - 4 && !(linelen == MAX_LINE - 3 && p + 1 < end && p[1] == '\n' && !binary)) {
 		    sv_catpvn(RETVAL, "=", 1);
 		    sv_catpvn(RETVAL, eol, eol_len);
 		    linelen = 0;
diff --git a/cpan/MIME-Base64/Changes b/cpan/MIME-Base64/Changes
index 4b60a89..595c8dc 100644
--- a/cpan/MIME-Base64/Changes
+++ b/cpan/MIME-Base64/Changes
@@ -1,3 +1,13 @@
+2010-01-25   Gisle Aas <gisle@ActiveState.com>
+
+   Release 3.09
+
+   The Quoted-Printable encoder would sometimes output lines
+   that were 77 characters long.  The max line length should be 76.
+   [RT#53919]
+
+
+
 2009-06-09   Gisle Aas <gisle@ActiveState.com>
 
    Release 3.08
diff --git a/cpan/MIME-Base64/QuotedPrint.pm b/cpan/MIME-Base64/QuotedPrint.pm
index aee13d6..ca3a042 100644
--- a/cpan/MIME-Base64/QuotedPrint.pm
+++ b/cpan/MIME-Base64/QuotedPrint.pm
@@ -7,7 +7,7 @@ require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(encode_qp decode_qp);
 
-$VERSION = "3.08";
+$VERSION = "3.09";
 
 use MIME::Base64;  # will load XS version of {en,de}code_qp()
 
diff --git a/cpan/MIME-Base64/t/quoted-print.t b/cpan/MIME-Base64/t/quoted-print.t
index 5bb8738..73c2301 100644
--- a/cpan/MIME-Base64/t/quoted-print.t
+++ b/cpan/MIME-Base64/t/quoted-print.t
@@ -62,7 +62,7 @@ y. -- H. L. Mencken=\n"],
    ["$x70!23"		=> "$x70!23=\n"],
    ["$x70!234"		=> "$x70!234=\n"],
    ["$x70!2345"		=> "$x70!2345=\n"],
-   ["$x70!23456"	=> "$x70!23456=\n"],
+   ["$x70!23456"	=> "$x70!2345=\n6=\n"],
    ["$x70!234567"	=> "$x70!2345=\n67=\n"],
    ["$x70!23456="	=> "$x70!2345=\n6=3D=\n"],
    ["$x70!23\n"		=> "$x70!23\n"],
@@ -78,8 +78,13 @@ y. -- H. L. Mencken=\n"],
    ["$x70!2===xxx"  => "$x70!2=3D=\n=3D=3Dxxx=\n"],
    ["$x70!23===xx"  => "$x70!23=\n=3D=3D=3Dxx=\n"],
    ["$x70!234===x"  => "$x70!234=\n=3D=3D=3Dx=\n"],
+   ["$x70!2="       => "$x70!2=3D=\n"],
+   ["$x70!23="      => "$x70!23=\n=3D=\n"],
+   ["$x70!234="     => "$x70!234=\n=3D=\n"],
+   ["$x70!2345="    => "$x70!2345=\n=3D=\n"],
+   ["$x70!23456="   => "$x70!2345=\n6=3D=\n"],
    ["$x70!2=\n"     => "$x70!2=3D\n"],
-   ["$x70!23=\n"    => "$x70!23=\n=3D\n"],
+   ["$x70!23=\n"    => "$x70!23=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"],
@@ -147,7 +152,7 @@ y. -- H. L. Mencken=\n"],
    ["$x70!23"		=> "$x70!23=\n"],
    ["$x70!234"		=> "$x70!234=\n"],
    ["$x70!2345"		=> "$x70!2345=\n"],
-   ["$x70!23456"	=> "$x70!23456=\n"],
+   ["$x70!23456"	=> "$x70!2345=\n6=\n"],
    ["$x70!234567"	=> "$x70!2345=\n67=\n"],
    ["$x70!23456="	=> "$x70!2345=\n6=7E=\n"],
    ["$x70!23\n"		=> "$x70!23\n"],