From 84130495f67b9d50e663f64c8e11293614bf0a24 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 8 Dec 2015 05:31:23 +0000 Subject: extmsg: try to fixup common errors Sometimes users (me :x) blindly append "raw" to a /t/ URL... --- lib/PublicInbox/ExtMsg.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index 50680471..82f4c63d 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -96,6 +96,8 @@ sub ext_msg { eval { require PublicInbox::Msgmap }; my $have_mm = $@ ? 0 : 1; if ($have_mm) { + my $tmp_mid = $mid; +again: my $cgi = $ctx->{cgi}; my $url = ref($cgi) eq 'CGI' ? $cgi->url(-base) . '/' : $cgi->base->as_string; @@ -106,13 +108,18 @@ sub ext_msg { my $mm = eval { PublicInbox::Msgmap->new($git_dir) }; $mm or next; - if (my $res = $mm->mid_prefixes($mid)) { + if (my $res = $mm->mid_prefixes($tmp_mid)) { $n_partial += scalar(@$res); $pfx->{res} = $res; push @partial, $pfx; } } + # fixup common errors: + if (!$n_partial && $tmp_mid =~ s,/[tTf],,) { + goto again; + } } + my $code = 404; my $h = PublicInbox::Hval->new_msgid($mid, 1); my $href = $h->as_href; -- cgit v1.2.3-24-ge0c7