提交 1bfd3631 编写于 作者: M Mark A Rada 提交者: Junio C Hamano

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: NMark Rada <marada@uwaterloo.ca>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 3f55e410
...@@ -160,7 +160,8 @@ BEGIN ...@@ -160,7 +160,8 @@ BEGIN
# 'suffix' => filename suffix, # 'suffix' => filename suffix,
# 'format' => --format for git-archive, # 'format' => --format for git-archive,
# 'compressor' => [compressor command and arguments] # 'compressor' => [compressor command and arguments]
# (array reference, optional)} # (array reference, optional)
# 'disabled' => boolean (optional)}
# #
'tgz' => { 'tgz' => {
'display' => 'tar.gz', 'display' => 'tar.gz',
...@@ -494,7 +495,8 @@ sub filter_snapshot_fmts { ...@@ -494,7 +495,8 @@ sub filter_snapshot_fmts {
exists $known_snapshot_format_aliases{$_} ? exists $known_snapshot_format_aliases{$_} ?
$known_snapshot_format_aliases{$_} : $_} @fmts; $known_snapshot_format_aliases{$_} : $_} @fmts;
@fmts = grep { @fmts = grep {
exists $known_snapshot_formats{$_} } @fmts; exists $known_snapshot_formats{$_} &&
!$known_snapshot_formats{$_}{'disabled'}} @fmts;
} }
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++"; our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
...@@ -5166,6 +5168,8 @@ sub git_snapshot { ...@@ -5166,6 +5168,8 @@ sub git_snapshot {
die_error(400, "Unknown snapshot format"); die_error(400, "Unknown snapshot format");
} elsif (!grep($_ eq $format, @snapshot_fmts)) { } elsif (!grep($_ eq $format, @snapshot_fmts)) {
die_error(403, "Unsupported snapshot format"); die_error(403, "Unsupported snapshot format");
} elsif ($known_snapshot_formats{$format}{'disabled'}) {
die_error(403, "Snapshot format not allowed");
} }
if (!defined $hash) { if (!defined $hash) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册