X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=ef5f4b3a25eb8199f51eac10072e86a949b5d134;hb=46742d95647c7a80cb2f60d5c134717dd91e22e2;hp=280d0ea5557024a790012d2bf0ab1e2d950f014b;hpb=e3124855ded54f9d9703bd7b72a584edb4422fbe;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 280d0ea5..ef5f4b3a 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -56,7 +56,7 @@ sub msg_page { } else { $first = $ibx->msg_by_mid($mid) or return; } - my $mime = PublicInbox::MIME->new($first); + my $mime = PublicInbox::Eml->new($first); $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; my $hdr = $ctx->{hdr} = $mime->header_obj; $ctx->{obuf} = _msg_page_prepare_obuf($hdr, $ctx, 0); @@ -243,7 +243,7 @@ sub index_entry { # scan through all parts, looking for displayable text $ctx->{mhref} = $mhref; $ctx->{obuf} = \$rv; - msg_iter($mime, \&add_text_body, $ctx, 1); + $mime->each_part(\&add_text_body, $ctx, 1); delete $ctx->{obuf}; # add the footer @@ -474,17 +474,16 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback } sub multipart_text_as_html { - # ($mime, $ctx) = @_; # msg_iter will do "$_[0] = undef" + # ($mime, $ctx) = @_; # each_part may do "$_[0] = undef" # scan through all parts, looking for displayable text - msg_iter($_[0], \&add_text_body, $_[1], 1); + $_[0]->each_part(\&add_text_body, $_[1], 1); } sub attach_link ($$$$;$) { my ($ctx, $ct, $p, $fn, $err) = @_; - my ($part, $depth, @idx) = @$p; - my $nl = $idx[-1] > 1 ? "\n" : ''; - my $idx = join('.', @idx); + my ($part, $depth, $idx) = @$p; + my $nl = substr($idx, -2) eq '.1' ? '' : "\n"; # like join("\n", ...) my $size = bytes::length($part->body); # hide attributes normally, unless we want to aid users in @@ -515,12 +514,12 @@ EOF undef; } -sub add_text_body { # callback for msg_iter +sub add_text_body { # callback for each_part my ($p, $ctx) = @_; my $upfx = $ctx->{mhref}; my $ibx = $ctx->{-inbox}; - # $p - from msg_iter: [ Email::MIME, depth, @idx ] - my ($part, $depth, @idx) = @$p; + # $p - from each_part: [ Email::MIME-like, depth, $idx ] + my ($part, $depth, $idx) = @$p; my $ct = $part->content_type || 'text/plain'; my $fn = $part->filename; my ($s, $err) = msg_part_text($part, $ct); @@ -536,11 +535,15 @@ sub add_text_body { # callback for msg_iter # always support diff-highlighting, but we can't linkify hunk # headers for solver unless some coderepo are configured: my $diff; - if ($s =~ /^(?:diff|---|\+{3}) /ms) { - # diffstat anchors do not link across attachments or messages: - $idx[0] = $upfx . $idx[0] if $upfx ne ''; - $ctx->{-apfx} = join('/', @idx); - $ctx->{-anchors} = {}; # attr => filename + if ($s =~ /^--- [^\n]+\n\+{3} [^\n]+\n@@ /ms) { + # diffstat anchors do not link across attachments or messages, + # -apfx is just a stable prefix for making diffstat anchors + # linkable to the first diff hunk w/o crossing attachments + $idx =~ tr!.!/!; # compatibility with previous versions + $ctx->{-apfx} = $upfx . $idx; + + # do attr => filename mappings for diffstats in git diffs: + $ctx->{-anchors} = {} if $s =~ /^diff --git /sm; $diff = 1; delete $ctx->{-long_path}; my $spfx; @@ -1096,6 +1099,7 @@ sub dump_topics { my @next_prev = @subj; # full copy my $omit = dedupe_subject($prev_subj, \@subj, ' "'); $prev_subj = \@next_prev; + $subj = join(' ', @subj); $subj = ascii_html($subj); obfuscate_addrs($obfs_ibx, $subj) if $obfs_ibx; $href = mid_href($mid);