Subject: | extra CRLF in header string results in space appended to last header |
Date: | Tue, 13 Feb 2007 21:56:37 +1000 |
To: | <bug-Email-Simple [...] rt.cpan.org> |
From: | "Barry Downes" <barry [...] bquotes.com> |
Distribution & Version: Email-Simple-1.998
Perl Version: v5.8.7 built for cygwin-thread-multi-64int
Operating system vendor & version:
$ uname -a
CYGWIN_NT-5.1 barry 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
Bug description:
The double-CRLF which terminates the headers is included in the header
string, in the case that the email body is present.
The header parsing in Email::Simple::Header interprets this as a final blank
header line, which is interpreted as a continuation of the last header.
This results in an extra space being appended to the last header (unless it
is blank).
In my case, this resulted in Email::MIME not recognising the
Content-Transfer-Encoding in a few emails, and failing to decode them.
My solution:
Exclude the terminating CRLF from the header string. (Be sure not to
include it in the body either.)
Patch:
$ svn diff -r276 Email
Index: Email/Simple.pm
===================================================================
--- Email/Simple.pm (revision 276)
+++ Email/Simple.pm (working copy)
@@ -60,6 +60,7 @@
my $head;
if (defined $pos) {
$head = substr $$text_ref, 0, $pos, '';
+ substr($head, -length($mycrlf)) = '';
} else {
$head = $$text_ref;
$text_ref = \'';