]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
www: allow including links to NNTP sites in HTML footer
[public-inbox.git] / lib / PublicInbox / View.pm
index 5f99644f8abaaebf630624c587b1b835dcd52058..ed3c96e80d6ec5297abbae0d1c523e515a42963d 100644 (file)
@@ -59,7 +59,7 @@ sub msg_reply {
 
        my ($arg, $link) = mailto_arg_link($hdr);
        push @$arg, '/path/to/YOUR_REPLY';
-       $arg = join(" \\\n    ", '', @$arg);
+       $arg = ascii_html(join(" \\\n    ", '', @$arg));
        <<EOF
 <hr><pre
 id=R><b>Reply instructions:</b>
@@ -94,7 +94,7 @@ sub in_reply_to {
        my ($hdr) = @_;
        my $irt = $hdr->header_raw('In-Reply-To');
 
-       return mid_clean($irt) if (defined $irt);
+       return mid_clean($irt) if defined $irt && $irt ne '';
 
        my $refs = $hdr->header_raw('References');
        if ($refs && $refs =~ /<([^>]+)>\s*\z/s) {
@@ -164,13 +164,17 @@ sub index_entry {
                "<a\nhref=\"$mhref\">permalink</a>" .
                " <a\nhref=\"${mhref}raw\">raw</a>" .
                " <a\nhref=\"${mhref}#R\">reply</a>";
+
+       my $hr;
        if (my $pct = $ctx->{pct}) { # used by SearchView.pm
                $rv .= "\t[relevance $pct->{$mid_raw}%]";
+               $hr = 1;
        } elsif ($mapping) {
                my $threaded = 'threaded';
                my $flat = 'flat';
                my $end = '';
                if ($ctx->{flat}) {
+                       $hr = 1;
                        $flat = "<b>$flat</b>";
                } else {
                        $threaded = "<b>$threaded</b>";
@@ -178,9 +182,12 @@ sub index_entry {
                $rv .= "\t[<a\nhref=\"${mhref}T/#u\">$flat</a>";
                $rv .= "|<a\nhref=\"${mhref}t/#u\">$threaded</a>]";
                $rv .= " <a\nhref=#r$id>$ctx->{s_nr}</a>";
+       } else {
+               $hr = $ctx->{-hr};
        }
 
-       $rv .= $more ? "\n\n" : "\n";
+       $rv .= $more ? '</pre><hr><pre>' : '</pre>' if $hr;
+       $rv;
 }
 
 sub pad_link ($$;$) {
@@ -619,15 +626,15 @@ sub mailto_arg_link {
        my $subj = $hdr->header('Subject') || '';
        $subj = "Re: $subj" unless $subj =~ /\bRe:/i;
        my $mid = $hdr->header_raw('Message-ID');
-       push @arg, '--in-reply-to='.ascii_html(squote_maybe(mid_clean($mid)));
+       push @arg, '--in-reply-to='.squote_maybe(mid_clean($mid));
        my $irt = uri_escape_utf8($mid);
        delete $cc{$to};
-       push @arg, '--to=' . ascii_html($to);
+       push @arg, "--to=$to";
        $to = uri_escape_utf8($to);
        $subj = uri_escape_utf8($subj);
-       my $cc = join(',', sort values %cc);
-       push @arg, '--cc=' . ascii_html($cc);
-       $cc = uri_escape_utf8($cc);
+       my @cc = sort values %cc;
+       push(@arg, map { "--cc=$_" } @cc);
+       my $cc = uri_escape_utf8(join(',', @cc));
        my $href = "mailto:$to?In-Reply-To=$irt&Cc=${cc}&Subject=$subj";
        $href =~ s/%20/+/g;