diff options
author | Eric Wong <normalperson@yhbt.net> | 2014-03-28 08:22:45 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2014-03-28 08:22:45 +0000 |
commit | 0b4b51e8ba8cf62c8da9312666d4866ff2403d6e (patch) | |
tree | 949f23b057a76ff566e9d8d1de7f71bf6c74c6ac /t | |
parent | 67e53d0875a7efcb958fb9680ea87216adaf06cc (diff) | |
download | public-inbox-0b4b51e8ba8cf62c8da9312666d4866ff2403d6e.tar.gz |
Some mailers do not correctly detect/set the Content-Type header; so attempt to keep messages based on our server-detected MIME type if application/octet-stream was specified.
Diffstat (limited to 't')
-rw-r--r-- | t/filter.t | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -278,5 +278,40 @@ sub count_body_parts { is(undef, $f->simple->header("Mail-Followup-To"), "mft stripped"); } +# multi-part with application/octet-stream +{ + my $os = 'application/octet-stream'; + my $parts = [ + Email::MIME->create( + attributes => { content_type => $os }, + body => <<EOF +#include <stdio.h> +int main(void) +{ + printf("Hello world\\n"); + return 0; +} +EOF + ), + Email::MIME->create( + attributes => { + filename => 'zero.data', + encoding => 'base64', + content_type => $os, + }, + body => ("\0" x 4096), + ) + ]; + my $email = Email::MIME->create( + header_str => [ From => 'a@example.com', Subject => 'blah' ], + parts => $parts, + ); + my $f = Email::Filter->new(data => $email->as_string); + is(1, PublicInbox::Filter->run($f->simple), "run was a success"); + my $parsed = Email::MIME->new($f->simple->as_string); + is(scalar $parsed->parts, 1, "only one remaining part"); + like($f->simple->header("X-Content-Filtered-By"), + qr/PublicInbox::Filter/, "XCFB header added"); +} done_testing(); |