unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] view: always compress Message-IDs for anchors
Date: Mon, 17 Aug 2015 08:06:09 +0000	[thread overview]
Message-ID: <1439798769-2261-1-git-send-email-e@80x24.org> (raw)

Valid URLs do not make valid anchor ids.
---
 lib/PublicInbox/MID.pm  | 4 ++--
 lib/PublicInbox/View.pm | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index c75aa0e..2f0c09f 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -19,7 +19,7 @@ sub mid_clean {
 
 # this is idempotent
 sub mid_compressed {
-	my ($mid) = @_;
+	my ($mid, $force) = @_;
 
 	# XXX dirty hack! FIXME!
 	# Some HTTP servers (apache2 2.2.22-13+deb7u5 on my system)
@@ -28,7 +28,7 @@ sub mid_compressed {
 	# or what; will need to debug...
 	return sha1_hex($mid) if (index($mid, '%') >= 0);
 
-	return $mid if (length($mid) <= MID_MAX);
+	return $mid if (!$force && length($mid) <= MID_MAX);
 	sha1_hex($mid);
 }
 
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 55e12f2..e7ca73d 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -477,7 +477,7 @@ sub linkify_refs {
 
 sub anchor_for {
 	my ($msgid) = @_;
-	'm' . mid_compressed(mid_clean($msgid));
+	'm' . mid_compressed(mid_clean($msgid), 1);
 }
 
 sub simple_dump {
-- 
EW


                 reply	other threads:[~2015-08-17  8:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1439798769-2261-1-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).