]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/MIME.pm
return perl-internal encoding even if MIME::Parser fails
[debbugs.git] / Debbugs / MIME.pm
index 3719d2e23f304f6659a33825aab6a3051b873ffe..afc077649939784e4cedf95a81d7b75efb04ded8 100644 (file)
@@ -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;