about summary refs log tree commit homepage
path: root/t/mda.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-11-13 21:51:42 +0000
committerEric Wong <e@80x24.org>2014-11-13 21:51:42 +0000
commitf0ba219d00c4634a055ec364092284630cdbe9e1 (patch)
treeee46d82b1912608f3d94a3a20742c663896e4dad /t/mda.t
parent75f6b34d08825b8d80de1ceda2a37e18ddde75a6 (diff)
downloadpublic-inbox-f0ba219d00c4634a055ec364092284630cdbe9e1.tar.gz
Sometimes people send HTML email and I forget to fixup in my
MUA during moderation.  Automatically strip out HTML portions
instead.
Diffstat (limited to 't/mda.t')
-rw-r--r--t/mda.t41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/mda.t b/t/mda.t
index fad96e5b..53712a56 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -205,14 +205,55 @@ EOF
         my $in = $simple->as_string;
 
         # now train it
+        # these should be overridden
         local $ENV{GIT_AUTHOR_EMAIL} = 'trainer@example.com';
         local $ENV{GIT_COMMITTER_EMAIL} = 'trainer@example.com';
+
         run([$learn, "ham"], \$in);
         is($?, 0, "learned ham without failure");
         my $msg = `ssoma cat $mid $maindir`;
         like($msg, qr/\Q$mid\E/, "ham message delivered");
         run([$learn, "ham"], \$in);
         is($?, 0, "learned ham idempotently ");
+
+        # ensure trained email is filtered, too
+        my $html_body = "<html><body>hi</body></html>";
+        my $parts = [
+                Email::MIME->create(
+                        attributes => {
+                                content_type => 'text/html; charset=UTF-8',
+                                encoding => 'base64',
+                        },
+                        body => $html_body,
+                ),
+                Email::MIME->create(
+                        attributes => {
+                                content_type => 'text/plain',
+                                encoding => 'quoted-printable',
+                        },
+                        body => 'hi = "bye"',
+                )
+        ];
+        $mid = 'multipart-html-sucks@11';
+        my $mime = Email::MIME->create(
+                header_str => [
+                  From => 'a@example.com',
+                  Subject => 'blah',
+                  Cc => $addr,
+                  'Message-ID' => "<$mid>",
+                  'Content-Type' => 'multipart/alternative',
+                ],
+                parts => $parts,
+        );
+
+        {
+                $in = $mime->as_string;
+                run([$learn, "ham"], \$in);
+                is($?, 0, "learned ham without failure");
+                $msg = `ssoma cat $mid $maindir`;
+                like($msg, qr/<\Q$mid\E>/, "ham message delivered");
+                unlike($msg, qr/<html>/i, '<html> filtered');
+        }
 }
 
 # faildir - emergency destination is maildir