]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 369835: email_in.pl should convert character encoding to utf8
authormkanat%bugzilla.org <>
Mon, 24 Sep 2007 02:53:58 +0000 (02:53 +0000)
committermkanat%bugzilla.org <>
Mon, 24 Sep 2007 02:53:58 +0000 (02:53 +0000)
Patch By Fedor Ezeev <fe@alterplast.ru> r=mkanat, a=mkanat

email_in.pl

index be9abadea57d05486c7e044fe6c38bfae2a241c4..ea5082844d7a87a3aea9bbad18de66e36dda54a6 100644 (file)
@@ -36,6 +36,7 @@ use Email::MIME;
 use Email::MIME::Attachment::Stripper;
 use Getopt::Long qw(:config bundling);
 use Pod::Usage;
+use Encode qw(encode decode);
 
 use Bugzilla;
 use Bugzilla::Bug qw(ValidateBugID);
@@ -295,9 +296,17 @@ sub get_text_alternative {
     my $body;
     foreach my $part (@parts) {
         my $ct = $part->content_type || 'text/plain';
+        my $charset = 'iso-8859-1';
+        if ($ct =~ /charset=([^;]+)/) {
+            $charset= $1;
+        }
         debug_print("Part Content-Type: $ct", 2);
+        debug_print("Part Character Encoding: $charset", 2);
         if (!$ct || $ct =~ /^text\/plain/i) {
             $body = $part->body;
+            if (Bugzilla->params->{'utf8'}) {
+                $body = encode('UTF-8', decode($charset, $body));
+            }
             last;
         }
     }