From 31c27f13b117efeebded6a89bd66166a60b8f093 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 7 Apr 2016 00:12:59 +0000 Subject: [PATCH] repobrowse: show invalid type for tree views Show some diagnostic information for non-(blob|tree) objects to perhaps help users figure out what to do with other objects. --- lib/PublicInbox/RepobrowseGitTree.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/RepobrowseGitTree.pm b/lib/PublicInbox/RepobrowseGitTree.pm index b7dd101e0..6e25200df 100644 --- a/lib/PublicInbox/RepobrowseGitTree.pm +++ b/lib/PublicInbox/RepobrowseGitTree.pm @@ -30,10 +30,15 @@ sub git_tree_stream { my $obj = "$id:$req->{expath}"; my ($hex, $type, $size) = $git->check($obj); - if (!defined($type) || ($type ne 'blob' && $type ne 'tree')) { - return $res->([404, ['Content-Type'=>'text/html'], + unless (defined($type)) { + return $res->([404, ['Content-Type'=>'text/plain'], ['Not Found']]); } + if ($type ne 'blob' && $type ne 'tree') { + return $res->([404, + ['Content-Type'=>'text/plain; charset=UTF-8'], + ["Unrecognized type ($type) for $obj\n"]]); + } my $fh = $res->([200, ['Content-Type'=>'text/html; charset=UTF-8']]); my $opts = { nofollow => 1 }; -- 2.47.3