Skip to content

Commit 1bfd363

Browse files
ferrous26gitster
authored andcommitted
gitweb: support to globally disable a snapshot format
Allow Gitweb administrators to set a 'disabled' key in the %known_snapshot_formats hash to disable a specific snapshot format. All formats are enabled by default to maintain backwards compatibility. Signed-off-by: Mark Rada <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f55e41 commit 1bfd363

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gitweb/gitweb.perl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ BEGIN
160160
# 'suffix' => filename suffix,
161161
# 'format' => --format for git-archive,
162162
# 'compressor' => [compressor command and arguments]
163-
# (array reference, optional)}
163+
# (array reference, optional)
164+
# 'disabled' => boolean (optional)}
164165
#
165166
'tgz' => {
166167
'display' => 'tar.gz',
@@ -494,7 +495,8 @@ sub filter_snapshot_fmts {
494495
exists $known_snapshot_format_aliases{$_} ?
495496
$known_snapshot_format_aliases{$_} : $_} @fmts;
496497
@fmts = grep {
497-
exists $known_snapshot_formats{$_} } @fmts;
498+
exists $known_snapshot_formats{$_} &&
499+
!$known_snapshot_formats{$_}{'disabled'}} @fmts;
498500
}
499501

500502
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@ -5166,6 +5168,8 @@ sub git_snapshot {
51665168
die_error(400, "Unknown snapshot format");
51675169
} elsif (!grep($_ eq $format, @snapshot_fmts)) {
51685170
die_error(403, "Unsupported snapshot format");
5171+
} elsif ($known_snapshot_formats{$format}{'disabled'}) {
5172+
die_error(403, "Snapshot format not allowed");
51695173
}
51705174

51715175
if (!defined $hash) {

0 commit comments

Comments
 (0)