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 <marada@uwaterloo.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mark A Rada committed
Aug 6, 2009 at 10:25 UTC
1bfd363184d5bd0eb81565bfa2cc1084f35dbbdf
1 file changed
+6
-2
gitweb/gitweb.perl
+6
-2
@@ -160,7 +160,8 @@ our %known_snapshot_formats = (
160
# 'suffix' => filename suffix,
161
# 'format' => --format for git-archive,
162
# 'compressor' => [compressor command and arguments]
163
- # (array reference, optional)}
163
+ # (array reference, optional)
164
+ # 'disabled' => boolean (optional)}
165
#
166
'tgz' => {
167
'display' => 'tar.gz',
@@ -494,7 +495,8 @@ sub filter_snapshot_fmts {
495
exists $known_snapshot_format_aliases{$_} ?
496
$known_snapshot_format_aliases{$_} : $_} @fmts;
497
@fmts = grep {
497
- exists $known_snapshot_formats{$_} } @fmts;
498
+ exists $known_snapshot_formats{$_} &&
499
+ !$known_snapshot_formats{$_}{'disabled'}} @fmts;
500
}
501
502
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@ -5166,6 +5168,8 @@ sub git_snapshot {
5168
die_error(400, "Unknown snapshot format");
5169
} elsif (!grep($_ eq $format, @snapshot_fmts)) {
5170
die_error(403, "Unsupported snapshot format");
5171
+ } elsif ($known_snapshot_formats{$format}{'disabled'}) {
5172
+ die_error(403, "Snapshot format not allowed");
5173
}
5174
5175
if (!defined $hash) {