From 8f0891d40ac377f21cc64f11177f0f2cffd909f2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 13 Mar 2025 20:35:04 +0000 Subject: [PATCH] www: disable legacy encoded Message-IDs for non-v1 For a while in the very early days of the v1 format, we supported SHA-1 checksums of the Message-ID in the URL. This never affected v2 inboxes nor extindex, and those URLs would've been broken if run through public-inbox-convert, anyways. --- lib/PublicInbox/WWW.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 05ec24162..50f182af1 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -253,10 +253,11 @@ sub invalid_inbox_mid { my $mid = $ctx->{mid} = uri_unescape($mid_ue); my $ibx = $ctx->{ibx}; - if ($mid =~ m!\A([a-f0-9]{2})([a-f0-9]{38})\z!) { + if ($ibx->can('version') && $ibx->version == 1 && + $mid =~ m!\A([a-f0-9]{2})([a-f0-9]{38})\z!) { my ($x2, $x38) = ($1, $2); # this is horrifically wasteful for legacy URLs: - my $str = $ctx->{ibx}->msg_by_path("$x2/$x38") or return; + my $str = $ibx->msg_by_path("$x2/$x38") or return; my $s = PublicInbox::Eml->new($str); $mid = PublicInbox::MID::mid_clean($s->header_raw('Message-ID')); return r301($ctx, $inbox, mid_escape($mid)); -- 2.47.2