Skip to content

Commit 77cdf0f

Browse files
committed
Merge branch 'jn/gitweb-unspecified-action'
* jn/gitweb-unspecified-action: gitweb: Fix actionless dispatch for non-existent objects
2 parents 7b718fb + 18ab83e commit 77cdf0f

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
@@ -1123,8 +1123,10 @@ sub dispatch {
11231123
if (!defined $action) {
11241124
if (defined $hash) {
11251125
$action = git_get_type($hash);
1126+
$action or die_error(404, "Object does not exist");
11261127
} elsif (defined $hash_base && defined $file_name) {
11271128
$action = git_get_type("$hash_base:$file_name");
1129+
$action or die_error(404, "File or directory does not exist");
11281130
} elsif (defined $project) {
11291131
$action = 'summary';
11301132
} else {
@@ -2391,7 +2393,7 @@ sub get_feed_info {
23912393
return unless (defined $project);
23922394
# some views should link to OPML, or to generic project feed,
23932395
# or don't have specific feed yet (so they should use generic)
2394-
return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
2396+
return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);
23952397

23962398
my $branch;
23972399
# 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
@@ -474,6 +474,14 @@ test_expect_success \
474474
'path_info: project/branch:dir/' \
475475
'gitweb_run "" "/.git/master:foo/"'
476476

477+
test_expect_success \
478+
'path_info: project/branch (non-existent)' \
479+
'gitweb_run "" "/.git/non-existent"'
480+
481+
test_expect_success \
482+
'path_info: project/branch:filename (non-existent branch)' \
483+
'gitweb_run "" "/.git/non-existent:non-existent"'
484+
477485
test_expect_success \
478486
'path_info: project/branch:file (non-existent)' \
479487
'gitweb_run "" "/.git/master:non-existent"'

0 commit comments

Comments
 (0)