]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: support to globally disable a snapshot format
authorMark A Rada <redacted>
Thu, 6 Aug 2009 14:25:39 +0000 (10:25 -0400)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 3eb82ef97a48c19e543cce6ff127774bfa2fdbbeee38e2005e2a392055312634..28833a8c90c8092f674e48ee6a6549768f3b8f048616f3347070115c0ea271df 100755 (executable)
@@ -161,7 +161,8 @@ our %known_snapshot_formats = (
        #       'suffix' => filename suffix,
        #       'format' => --format for git-archive,
        #       'compressor' => [compressor command and arguments]
-       #                       (array reference, optional)}
+       #                       (array reference, optional)
+       #       'disabled' => boolean (optional)}
        #
        'tgz' => {
                'display' => 'tar.gz',
@@ -495,7 +496,8 @@ sub filter_snapshot_fmts {
                exists $known_snapshot_format_aliases{$_} ?
                       $known_snapshot_format_aliases{$_} : $_} @fmts;
        @fmts = grep {
-               exists $known_snapshot_formats{$_} } @fmts;
+               exists $known_snapshot_formats{$_} &&
+               !$known_snapshot_formats{$_}{'disabled'}} @fmts;
 }
 
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@ -5182,6 +5184,8 @@ sub git_snapshot {
                die_error(400, "Unknown snapshot format");
        } elsif (!grep($_ eq $format, @snapshot_fmts)) {
                die_error(403, "Unsupported snapshot format");
+       } elsif ($known_snapshot_formats{$format}{'disabled'}) {
+               die_error(403, "Snapshot format not allowed");
        }
 
        if (!defined $hash) {
This page took 0.356737 seconds and 4 git commands to generate.