From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/7] view: avoid links to unknown compressed Message-IDs
Date: Wed, 2 Sep 2015 06:59:38 +0000 [thread overview]
Message-ID: <1441177179-16628-7-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1441177179-16628-1-git-send-email-e@80x24.org>
Compressed Message-IDs are irreversible and may not be used
at other sites. So avoid compressing Message-IDs we do not
know about so users have a chance of finding the message in
other archives by doing a Message-ID lookup.
---
lib/PublicInbox/Hval.pm | 4 ++--
lib/PublicInbox/View.pm | 33 +++++++++++++++++++--------------
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index 21efe40..0445e57 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -25,9 +25,9 @@ sub new {
}
sub new_msgid {
- my ($class, $msgid) = @_;
+ my ($class, $msgid, $no_compress) = @_;
$msgid = mid_clean($msgid);
- $class->new($msgid, mid_compress($msgid));
+ $class->new($msgid, $no_compress ? $msgid : mid_compress($msgid));
}
sub new_oneline {
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 98fc133..1528a87 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -132,7 +132,7 @@ sub index_entry {
if (defined $irt) {
unless (defined $parent_anchor) {
- my $v = PublicInbox::Hval->new_msgid($irt);
+ my $v = PublicInbox::Hval->new_msgid($irt, 1);
$v = $v->as_href;
$parent_anchor = "${path}$v/";
}
@@ -452,22 +452,25 @@ sub thread_inline {
if ($nr <= 1) {
$$dst .= "\n[no followups, yet]\n";
- return;
+ return (undef, in_reply_to($cur));
}
my $upfx = $full_pfx ? '' : '../';
$$dst .= "\n\n~$nr messages in thread: ".
"(<a\nhref=\"${upfx}t/#u\">expand</a>)\n";
my $subj = $srch->subject_path($cur->header('Subject'));
+ my $parent = in_reply_to($cur);
my $state = {
seen => { $subj => 1 },
srch => $srch,
cur => $mid,
+ parent_cmp => $parent ? mid_compress($parent) : '',
+ parent => $parent,
};
for (thread_results(load_results($res))->rootset) {
inline_dump($dst, $state, $upfx, $_, 0);
}
- $state->{next_msg};
+ ($state->{next_msg}, $state->{parent});
}
sub _parent_headers_nosrch {
@@ -476,7 +479,7 @@ sub _parent_headers_nosrch {
my $irt = in_reply_to($header_obj);
if (defined $irt) {
- my $v = PublicInbox::Hval->new_msgid($irt);
+ my $v = PublicInbox::Hval->new_msgid($irt, 1);
my $html = $v->as_html;
my $href = $v->as_href;
$rv .= "In-Reply-To: <";
@@ -493,7 +496,7 @@ sub _parent_headers_nosrch {
foreach my $ref (@raw_refs) {
next if $seen{$ref};
$seen{$ref} = 1;
- push @refs, linkify_ref($ref);
+ push @refs, linkify_ref_nosrch($ref);
}
if (@refs) {
@@ -536,12 +539,11 @@ sub html_footer {
my $upfx = $full_pfx ? '../' : '../../';
my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
if ($idx && $srch) {
- my $next = thread_inline(\$idx, $ctx, $mime, $full_pfx);
- $irt = in_reply_to($mime->header_obj);
- if (defined $irt) {
- $irt = PublicInbox::Hval->new_msgid($irt);
- $irt = $irt->as_href;
- $irt = "<a\nhref=\"$upfx$irt/\">parent</a> ";
+ my ($next, $p) = thread_inline(\$idx, $ctx, $mime, $full_pfx);
+ if (defined $p) {
+ $p = PublicInbox::Hval->new_oneline($p);
+ $p = $p->as_href;
+ $irt = "<a\nhref=\"$upfx$p/\">parent</a> ";
} else {
$irt = ' ' x length('parent ');
}
@@ -557,8 +559,8 @@ sub html_footer {
"$irt<a\nhref=\"" . ascii_html($href) . '">reply</a>' . $idx;
}
-sub linkify_ref {
- my $v = PublicInbox::Hval->new_msgid($_[0]);
+sub linkify_ref_nosrch {
+ my $v = PublicInbox::Hval->new_msgid($_[0], 1);
my $html = $v->as_html;
my $href = $v->as_href;
"<<a\nhref=\"../$href/\">$html</a>>";
@@ -699,8 +701,11 @@ sub _inline_header {
sub inline_dump {
my ($dst, $state, $upfx, $node, $level) = @_;
return unless $node;
- return if $state->{stopped};
if (my $mime = $node->message) {
+ my $mid = mid_clean($mime->header('Message-ID'));
+ if ($mid eq $state->{parent_cmp}) {
+ $state->{parent} = $mid;
+ }
_inline_header($dst, $state, $upfx, $mime, $level);
}
inline_dump($dst, $state, $upfx, $node->child, $level+1);
--
EW
next prev parent reply other threads:[~2015-09-02 6:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 6:59 [PATCH 0/7] improved thread views and 404 reductions Eric Wong
2015-09-02 6:59 ` [PATCH 1/7] view: close possible race condition in thread view Eric Wong
2015-09-02 6:59 ` [PATCH 2/7] view: optional flat view for recent messages Eric Wong
2015-09-02 6:59 ` [PATCH 3/7] view: account for missing In-Reply-To header Eric Wong
2015-09-02 6:59 ` [PATCH 4/7] view: simplify parent anchoring code Eric Wong
2015-09-02 6:59 ` [PATCH 5/7] view: pre-anchor entries for flat view Eric Wong
2015-09-02 6:59 ` Eric Wong [this message]
2015-09-02 6:59 ` [PATCH 7/7] implement external Message-ID finder Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441177179-16628-7-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).