Skip to content

Commit bd193f4

Browse files
committed
Merge branch 'jn/gitweb-unspecified-action' into maint-1.7.8
* jn/gitweb-unspecified-action: gitweb: Fix actionless dispatch for non-existent objects
2 parents e521850 + 18ab83e commit bd193f4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,10 @@ sub dispatch {
11221122
if (!defined $action) {
11231123
if (defined $hash) {
11241124
$action = git_get_type($hash);
1125+
$action or die_error(404, "Object does not exist");
11251126
} elsif (defined $hash_base && defined $file_name) {
11261127
$action = git_get_type("$hash_base:$file_name");
1128+
$action or die_error(404, "File or directory does not exist");
11271129
} elsif (defined $project) {
11281130
$action = 'summary';
11291131
} else {
@@ -2364,7 +2366,7 @@ sub get_feed_info {
23642366
return unless (defined $project);
23652367
# some views should link to OPML, or to generic project feed,
23662368
# or don't have specific feed yet (so they should use generic)
2367-
return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
2369+
return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);
23682370

23692371
my $branch;
23702372
# branches refs uses 'refs/heads/' prefix (fullname) to differentiate

t/t9500-gitweb-standalone-no-errors.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ test_expect_success \
403403
'path_info: project/branch:dir/' \
404404
'gitweb_run "" "/.git/master:foo/"'
405405

406+
test_expect_success \
407+
'path_info: project/branch (non-existent)' \
408+
'gitweb_run "" "/.git/non-existent"'
409+
410+
test_expect_success \
411+
'path_info: project/branch:filename (non-existent branch)' \
412+
'gitweb_run "" "/.git/non-existent:non-existent"'
413+
406414
test_expect_success \
407415
'path_info: project/branch:file (non-existent)' \
408416
'gitweb_run "" "/.git/master:non-existent"'

0 commit comments

Comments
 (0)