]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAttach.pm
wwwstream: use parent.pm and no warnings
[public-inbox.git] / lib / PublicInbox / WwwAttach.pm
index b10099077e1b2591a736b3483d49c7fb83dbf519..7e8496d7ab9c59c4a55670860d2255b02e7d7289 100644 (file)
@@ -6,9 +6,8 @@ package PublicInbox::WwwAttach; # internal package
 use strict;
 use warnings;
 use bytes (); # only for bytes::length
-use Email::MIME::ContentType qw(parse_content_type);
-use PublicInbox::MIME;
-use PublicInbox::MsgIter;
+use PublicInbox::EmlContentFoo qw(parse_content_type);
+use PublicInbox::Eml;
 
 sub get_attach_i { # ->each_part callback
        my ($part, $depth, $idx) = @{$_[0]};
@@ -18,8 +17,7 @@ sub get_attach_i { # ->each_part callback
        my $ct = $part->content_type;
        $ct = parse_content_type($ct) if $ct;
 
-       # discrete == type, we remain Debian wheezy-compatible
-       if ($ct && (($ct->{discrete} || '') eq 'text')) {
+       if ($ct && (($ct->{type} || '') eq 'text')) {
                # display all text as text/plain:
                my $cset = $ct->{attributes}->{charset};
                if ($cset && ($cset =~ /\A[a-zA-Z0-9_\-]+\z/)) {
@@ -38,7 +36,7 @@ sub get_attach ($$$) {
        my ($ctx, $idx, $fn) = @_;
        my $res = [ 404, [ 'Content-Type', 'text/plain' ], [ "Not found\n" ] ];
        my $mime = $ctx->{-inbox}->msg_by_mid($ctx->{mid}) or return $res;
-       $mime = PublicInbox::MIME->new($mime);
+       $mime = PublicInbox::Eml->new($mime);
        $res->[3] = $idx;
        $mime->each_part(\&get_attach_i, $res, 1);
        pop @$res; # cleanup before letting PSGI server see it