unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] view: always compress Message-IDs for anchors
@ 2015-08-17  8:06 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-17  8:06 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-17  8:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17  8:06 [PATCH] view: always compress Message-IDs for anchors Eric Wong

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).