MANIFEST | 1 + lib/PublicInbox/TestCommon.pm | 22 ++++++++++++++-------- lib/PublicInbox/View.pm | 11 ++++++----- xt/mem-msgview.t | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/MANIFEST b/MANIFEST index 845fee7b486f80fab935f60e1aa3fb57a2479640..914015adf64eba929de863a0f9115e7461f3c0aa 100644 --- a/MANIFEST +++ b/MANIFEST @@ -296,6 +296,7 @@ t/www_static.t t/xcpdb-reshard.t xt/git-http-backend.t xt/git_async_cmp.t +xt/mem-msgview.t xt/msgtime_cmp.t xt/nntpd-validate.t xt/perf-msgview.t diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 68785969fc8a27c939c9b74e74ee159181bb73ed..d6d1e9394937c1ea652ccb06b52b41d82cc06470 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -195,14 +195,20 @@ my $fhref = []; my $spawn_opt = {}; for my $fd (0..2) { my $redir = $opt->{$fd}; - next unless ref($redir); - open my $fh, '+>', undef or die "open: $!"; - $fhref->[$fd] = $fh; - $spawn_opt->{$fd} = $fh; - next if $fd > 0; - $fh->autoflush(1); - print $fh $$redir or die "print: $!"; - seek($fh, 0, SEEK_SET) or die "seek: $!"; + my $ref = ref($redir); + if ($ref eq 'SCALAR') { + open my $fh, '+>', undef or die "open: $!"; + $fhref->[$fd] = $fh; + $spawn_opt->{$fd} = $fh; + next if $fd > 0; + $fh->autoflush(1); + print $fh $$redir or die "print: $!"; + seek($fh, 0, SEEK_SET) or die "seek: $!"; + } elsif ($ref eq 'GLOB') { + $spawn_opt->{$fd} = $fhref->[$fd] = $redir; + } elsif ($ref) { + die "unable to deal with $ref $redir"; + } } if ($run_mode == 0) { # spawn an independent new process, like real-world use cases: diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index c38a12894b21dbc8fccd0d9f7f747c57f977ac8f..69948c4a07cea5da391241571df9a93b37748b05 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -31,8 +31,8 @@ if ($nr == 1) { # $more cannot be true w/o $smsg being defined: my $upfx = $more ? '../'.mid_escape($ctx->{smsg}->mid).'/' : ''; $ctx->{tip} . - multipart_text_as_html($ctx->{mime}, $upfx, $ctx) . - '
' . html_footer($hdr, 1, $ctx) . '' . msg_reply($ctx, $hdr) }; @@ -56,7 +56,8 @@ sub msg_html { my ($ctx, $mime, $more, $smsg) = @_; my $ibx = $ctx->{-inbox}; $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; - $ctx->{tip} = _msg_html_prepare($mime->header_obj, $ctx, $more, 0); + my $hdr = $ctx->{hdr} = $mime->header_obj; + $ctx->{tip} = _msg_html_prepare($hdr, $ctx, $more, 0); $ctx->{more} = $more; $ctx->{end_nr} = 2; $ctx->{smsg} = $smsg; @@ -95,8 +96,8 @@ $smsg = $ibx->smsg_mime($smsg); my $next = $ibx->over->next_by_mid($mid, \$id, \$prev); @$more = $next ? ($id, $prev, $next) : (); if ($smsg) { - my $mime = $smsg->{mime}; my $upfx = '../' . mid_escape($smsg->mid) . '/'; + my $mime = delete $smsg->{mime}; _msg_html_prepare($mime->header_obj, $ctx, $more, $nr) . multipart_text_as_html($mime, $upfx, $ctx) . '