From: Don Armstrong Date: Tue, 12 Mar 2013 21:55:24 +0000 (-0700) Subject: return perl-internal encoding even if MIME::Parser fails X-Git-Tag: release/2.6.0~313^2 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=refs%2Fheads%2Fdon%2Fprocesscleanup return perl-internal encoding even if MIME::Parser fails --- diff --git a/Debbugs/MIME.pm b/Debbugs/MIME.pm index 3719d2e..afc0776 100644 --- a/Debbugs/MIME.pm +++ b/Debbugs/MIME.pm @@ -115,6 +115,9 @@ sub parse my @msg = split /\n/, $_[0]; my $i; + # assume us-ascii unless charset is set; probably bad, but we + # really shouldn't get to this point anyway + my $charset = 'us-ascii'; for ($i = 0; $i <= $#msg; ++$i) { $_ = $msg[$i]; last unless length; @@ -122,10 +125,12 @@ sub parse ++$i; $_ .= "\n" . $msg[$i]; } + if (/charset=\"([^\"]+)\"/) { + $charset = $1; + } push @headerlines, $_; } - - @bodylines = @msg[$i .. $#msg]; + @bodylines = map {convert_to_utf8($_,$charset)} @msg[$i .. $#msg]; } rmtree $tempdir, 0, 1;