]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Mbox.pm
mbox: show application/mbox for obfuscated inboxes
[public-inbox.git] / lib / PublicInbox / Mbox.pm
index dc41548b87ce68726dc41aa79bd571589a150641..88daba752153385ed74656cae0699078a65139c3 100644 (file)
@@ -6,15 +6,18 @@
 package PublicInbox::Mbox;
 use strict;
 use warnings;
-use PublicInbox::MID qw/mid_clean/;
-use URI::Escape qw/uri_escape_utf8/;
+use PublicInbox::MID qw/mid_clean mid_escape/;
 require Email::Simple;
 
 sub emit1 {
        my ($ctx, $msg) = @_;
        $msg = Email::Simple->new($msg);
-       # single message should be easily renderable in browsers
-       [200, ['Content-Type', 'text/plain'], [ msg_str($ctx, $msg)] ]
+
+       # single message should be easily renderable in browsers,
+       # unless obfuscation is enabled :<
+       [ 200, [ 'Content-Type',
+         $ctx->{-inbox}->{obfuscate} ? 'application/mbox' : 'text/plain' ],
+        [ msg_str($ctx, $msg)] ]
 }
 
 sub msg_str {
@@ -29,7 +32,7 @@ sub msg_str {
        my $ibx = $ctx->{-inbox};
        my $base = $ibx->base_url($ctx->{env});
        my $mid = mid_clean($header_obj->header('Message-ID'));
-       $mid = uri_escape_utf8($mid);
+       $mid = mid_escape($mid);
        my @append = (
                'Archived-At', "<$base$mid/>",
                'List-Archive', "<$base>",
@@ -116,7 +119,7 @@ sub new {
                cb => $cb,
                ctx => $ctx,
                msgs => [],
-               opts => { asc => 1, offset => 0 },
+               opts => { offset => 0 },
        }, $class;
 }