about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-29 09:57:47 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-29 09:59:59 +0000
commit8f9e9ae77525418a4d916d80297c66c4c854b16e (patch)
tree068ff0d286de0ea5fd23065ad87293a50a7c05de /lib/PublicInbox/View.pm
parentd8e714970bbdf130568e17c114e747b5c3464d19 (diff)
downloadpublic-inbox-8f9e9ae77525418a4d916d80297c66c4c854b16e.tar.gz
By using the "primary" Message-ID in WwwAttach, we can avoid
conflicts in the links we use for downloading attachments.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 133c30a8..aad860e9 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -24,7 +24,7 @@ sub th_pfx ($) { $_[0] == 0 ? '' : TCHILD };
 # public functions: (unstable)
 
 sub msg_html {
-        my ($ctx, $mime, $more) = @_;
+        my ($ctx, $mime, $more, $smsg) = @_;
         my $hdr = $mime->header_obj;
         my $ibx = $ctx->{-inbox};
         my $obfs_ibx = $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
@@ -33,7 +33,9 @@ sub msg_html {
         PublicInbox::WwwStream->response($ctx, 200, sub {
                 my ($nr, undef) = @_;
                 if ($nr == 1) {
-                        $tip . multipart_text_as_html($mime, '', $obfs_ibx) .
+                        # $more cannot be true w/o $smsg being defined:
+                        my $upfx = $more ? '../'.mid_escape($smsg->mid).'/' : '';
+                        $tip . multipart_text_as_html($mime, $upfx, $obfs_ibx) .
                                 '</pre><hr>'
                 } elsif ($more && @$more) {
                         ++$end;
@@ -57,12 +59,13 @@ sub msg_page {
         my $mid = $ctx->{mid};
         my $ibx = $ctx->{-inbox};
         my ($first, $more, $head, $tail, $db);
+        my $smsg;
         if (my $srch = $ibx->search) {
                 $srch->retry_reopen(sub {
                         ($head, $tail, $db) = $srch->each_smsg_by_mid($mid);
                         for (; !defined($first) && $head != $tail; $head++) {
                                 my @args = ($head, $db, $mid);
-                                my $smsg = PublicInbox::SearchMsg->get(@args);
+                                $smsg = PublicInbox::SearchMsg->get(@args);
                                 $first = $ibx->msg_by_smsg($smsg);
                         }
                         if ($head != $tail) {
@@ -73,7 +76,7 @@ sub msg_page {
         } else {
                 $first = $ibx->msg_by_mid($mid) or return;
         }
-        msg_html($ctx, PublicInbox::MIME->new($first), $more);
+        msg_html($ctx, PublicInbox::MIME->new($first), $more, $smsg);
 }
 
 sub msg_html_more {
@@ -93,8 +96,9 @@ sub msg_html_more {
                 }
                 if ($smsg) {
                         my $mime = $smsg->{mime};
+                        my $upfx = '../' . mid_escape($smsg->mid) . '/';
                         _msg_html_prepare($mime->header_obj, $ctx, $more, $nr) .
-                                multipart_text_as_html($mime, '',
+                                multipart_text_as_html($mime, $upfx,
                                                         $ctx->{-obfs_ibx}) .
                                 '</pre><hr>'
                 } else {