lib/PublicInbox/View.pm | 78 +++++++++++++++++++++++++++++------------------------ diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 2ba51182dfcc39f3fe2126885406cc28f8d271f4..391e3ad79b0dad9c01ce5df4f738b2e5ede34719 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -146,7 +146,7 @@ my (undef, $ctx, $foot, $srch) = @_; my $mid = mid_compressed($ctx->{mid}); my $res = $srch->get_thread($mid); my $rv = ''; - my $msgs = load_results($ctx, $res); + my $msgs = load_results($res); my $nr = scalar @$msgs; return $rv if $nr == 0; require PublicInbox::Thread; @@ -154,7 +154,11 @@ my $th = PublicInbox::Thread->new(@$msgs); $th->thread; $th->order(*PublicInbox::Thread::sort_ts); my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ]; - thread_entry(\$rv, $state, $_, 0) for $th->rootset; + { + require PublicInbox::GitCatFile; + my $git = PublicInbox::GitCatFile->new($ctx->{git_dir}); + thread_entry(\$rv, $git, $state, $_, 0) for $th->rootset; + } my $final_anchor = $state->[3]; my $next = ""; @@ -173,7 +177,7 @@ my (undef, $ctx, $foot, $srch) = @_; my $path = $ctx->{subject_path}; my $res = $srch->get_subject_path($path); my $rv = ''; - my $msgs = load_results($ctx, $res); + my $msgs = load_results($res); my $nr = scalar @$msgs; return $rv if $nr == 0; require PublicInbox::Thread; @@ -181,7 +185,11 @@ my $th = PublicInbox::Thread->new(@$msgs); $th->thread; $th->order(*PublicInbox::Thread::sort_ts); my $state = [ $srch, { root_anchor => 'dummy' }, undef, 0 ]; - thread_entry(\$rv, $state, $_, 0) for $th->rootset; + { + require PublicInbox::GitCatFile; + my $git = PublicInbox::GitCatFile->new($ctx->{git_dir}); + thread_entry(\$rv, $git, $state, $_, 0) for $th->rootset; + } my $final_anchor = $state->[3]; my $next = "end of thread\n"; @@ -197,7 +205,10 @@ return $rv if $part->subparts; # walk_parts already recurses my $ct = $part->content_type; # account for filter bugs... - return '' if defined $ct && $ct =~ m!\btext/[xh]+tml\b!i; + if (defined $ct && $ct =~ m!\btext/[xh]+tml\b!i) { + $part->body_set(''); + return ''; + } my $enc = enc_for($ct, $enc_msg); @@ -224,7 +235,9 @@ if (length $s) { # kill per-line trailing whitespace $s =~ s/[ \t]+$//sgm; - $rv .= $s . "\n"; + $rv .= $s; + $s = undef; + $rv .= "\n"; } $rv; } @@ -335,10 +348,13 @@ sub add_text_body { my ($enc, $part, $part_nr, $full_pfx) = @_; my $n = 0; - my $s = ascii_html($enc->decode($part->body)); + my $nr = 0; + my $s = $part->body; + $part->body_set(''); + $s = $enc->decode($s); + $s = ascii_html($s); my @lines = split(/\n/, $s); $s = ''; - my $nr = 0; my @quot; while (defined(my $cur = shift @lines)) { if ($cur !~ /^>/) { @@ -538,10 +554,10 @@ } sub thread_followups { my ($dst, $root, $res) = @_; - my @msgs = map { $_->mini_mime } @{$res->{msgs}}; + my $msgs = load_results($res); require PublicInbox::Thread; $root->header_set('X-PI-TS', '0'); - my $th = PublicInbox::Thread->new($root, @msgs); + my $th = PublicInbox::Thread->new($root, @$msgs); $th->thread; $th->order(*PublicInbox::Thread::sort_ts); my $srch = $res->{srch}; @@ -559,43 +575,35 @@ "