unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] view: do not recompress already-compressed MID for anchors
@ 2015-08-17 20:17 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-17 20:17 UTC (permalink / raw)
  To: meta

This is merely for display, so on the off chance somebody does
send a 40-byte MID with nothing but hexadecimal characters,
the worst that could happen is we repeat an anchor name in the
rendered HTML.  This has no impact on git archival or Xapian
indexing.
---
 lib/PublicInbox/View.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index e7ca73d..6fbc366 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -477,7 +477,11 @@ sub linkify_refs {
 
 sub anchor_for {
 	my ($msgid) = @_;
-	'm' . mid_compressed(mid_clean($msgid), 1);
+	my $id = $msgid;
+	if ($id !~ /\A[a-f0-9]{40}\z/) {
+		$id = mid_compressed(mid_clean($id), 1);
+	}
+	'm' . $id;
 }
 
 sub simple_dump {
-- 
EW


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

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

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 20:17 [PATCH] view: do not recompress already-compressed MID 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).