]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/MIME.pm
merge changes from source
[debbugs.git] / Debbugs / MIME.pm
index 1269e17b4a077ea86f148a2d546372b7f20376a6..f5d6acd14600fbbf5af5ad0713cc98c61e337415 100644 (file)
@@ -1,3 +1,13 @@
+# This module is part of debbugs, and is released
+# under the terms of the GPL version 2, or any later
+# version at your option.
+# See the file README and COPYING for more information.
+#
+# [Other people have contributed to this file; their copyrights should
+# go here too.]
+# Copyright 2006 by Don Armstrong <don@donarmstrong.com>.
+
+
 package Debbugs::MIME;
 
 use strict;
@@ -131,7 +141,9 @@ sub create_mime_message{
 
      # Build the message
      # MIME::Entity is stupid, and doesn't rfc1522 encode its headers, so we do it for it.
-     my $msg = MIME::Entity->build(map{encode_rfc1522($_)} @{$headers},
+     my $msg = MIME::Entity->build('Content-Type' => 'text/plain; charset=utf-8',
+                                  'Encoding'     => 'quoted-printable',
+                                  (map{encode_rfc1522($_)} @{$headers}),
                                   Data    => $body
                                  );
 
@@ -208,9 +220,13 @@ sub decode_rfc1522 ($)
 {
     my ($string) = @_;
 
+    # this is craptacular, but leading space is hacked off by unmime.
+    # Save it.
+    my $leading_space = '';
+    $leading_space = $1 if $string =~ s/^(\s+)//;
     # unmime calls the default MIME::WordDecoder handler set up at
     # initialization time.
-    return MIME::WordDecoder::unmime($string);
+    return $leading_space . MIME::WordDecoder::unmime($string);
 }
 
 =head2 encode_rfc1522