git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 2/2] gitweb: support to globally enable/disable a snapshot format

From
Mark A Rada <marada@uwaterloo.ca>
Date
Aug 1, 2009, 20:06 UTC
Message-ID
<1CE4F545-1ACA-4786-B0F2-EE7C746E6585@uwaterloo.ca>
Comments? I've integrated Jakub Narebski's  suggestions.

-- Mark A Rada (ferrous26) marada@uwaterloo.ca

------->8-------------
From: Mark Rada <marada@uwaterloo.ca>
Date: Sat, 1 Aug 2009 13:24:03 -0400
Subject: [PATCH 2/2] gitweb: support to globally enable/disable a  
snapshot format

I added a 'disabled' variable to to the $known_snapshot_formats keys so that a Gitweb administrator can globally enable or disable a specific format for snapshots.

All formats are enabled by default because project specific overriding is disabled by default.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
  gitweb/gitweb.perl |   17 ++++++++++++-----
  1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3398163..a59569f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -167,27 +167,31 @@ our %known_snapshot_formats = (
  		'type' => 'application/x-gzip',
  		'suffix' => '.tar.gz',
  		'format' => 'tar',
-		'compressor' => ['gzip']},
+		'compressor' => ['gzip'],
+		'disabled' => 0},

  	'tbz2' => {
  		'display' => 'tar.bz2',
  		'type' => 'application/x-bzip2',
  		'suffix' => '.tar.bz2',
  		'format' => 'tar',
-		'compressor' => ['bzip2']},
+		'compressor' => ['bzip2'],
+		'disabled' => 0},

  	'txz' => {
  		'display' => 'tar.xz',
  		'type' => 'application/x-xz',
  		'suffix' => '.tar.xz',
  		'format' => 'tar',
-		'compressor' => ['xz']},
+		'compressor' => ['xz'],
+		'disabled' => 0},

  	'zip' => {
  		'display' => 'zip',
  		'type' => 'application/x-zip',
  		'suffix' => '.zip',
-		'format' => 'zip'},
+		'format' => 'zip',
+		'disabled' => 0},
  );

  # Aliases so we understand old gitweb.snapshot values in repository
@@ -502,7 +506,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++";
@@ -5171,6 +5176,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) {
-- 
1.6.4
Next: Jakub Narebski
Message 1 of 4 in “[PATCHv2 2/2] gitweb: support to globally enable/disable a snapshot format”
  1. Mark A RadaAug 1, 2009
  2. Jakub NarebskiAug 1, 2009
  3. Mark A RadaAug 1, 2009
  4. Mark A RadaAug 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.