]> git.donarmstrong.com Git - debbugs.git/commitdiff
* Encode all messages with quoted-printable when appropriate
authorDon Armstrong <don@archimedes>
Wed, 7 Jun 2006 07:14:16 +0000 (00:14 -0700)
committerDon Armstrong <don@archimedes>
Wed, 7 Jun 2006 07:14:16 +0000 (00:14 -0700)
 * Add a test to make sure that messages which are created don't have
   8-bit stuff anywhere.

Debbugs/MIME.pm
t/01_mime.t

index 1269e17b4a077ea86f148a2d546372b7f20376a6..9099fa1b038d8aaa99ab62bc4fc5150732768cc6 100644 (file)
@@ -131,7 +131,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
                                  );
 
index acffce93ad0a94e85e43891d5aa2c7d538c1e569..9a67089dcacf475784c5381b3a743a411778aecb 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: cperl;-*-
 # $Id: 01_mime.t,v 1.1 2005/08/17 21:46:17 don Exp $
 
-use Test::More tests => 3;
+use Test::More tests => 4;
 
 use warnings;
 use strict;
@@ -27,4 +27,16 @@ ok(Debbugs::MIME::decode_rfc1522(q(=?iso-8859-1?Q?D=F6n_Armstr=F3ng?= <don@donar
 ok(Debbugs::MIME::decode_rfc1522(Debbugs::MIME::encode_rfc1522($test_str)) eq $test_str,
   "encode_rfc1522 encodes strings that decode_rfc1522 can decode");
 
+# Make sure that create_mime_message has encoded headers and doesn't enclude any 8-bit characters
+
+$test_str = Encode::encode("UTF-8",$test_str);
+ok(Debbugs::MIME::create_mime_message([Subject => $test_str,
+                                      From    => $test_str,
+                                     ],
+                                     $test_str,
+                                     [],
+                                    ) !~ m{([\xF0-\xFF]+)},
+   "create_mime_message properly encodes 8bit messages."
+  );
+
 # XXX figure out how to test parse