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

[RFC/PATCH 1/3] gitweb: improve snapshot error handling

From
Mark Rada <marada@uwaterloo.ca>
Date
Aug 24, 2009, 03:09 UTC
Message-ID
<4A920470.1090709@mailservices.uwaterloo.ca>
In-Reply-To
<4A91C74D.1080908@vilain.net>

Ok, this is just a resend of the first patch in my set from earlier, but with some of the commit message reworded, namely the subject (as suggested by Sam Vilain).

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

--->8--- In the second block of checks to validate a snapshot request, the last check is never executed because the second last check is a superset of the last check.

This change will switch the order of the last two checks, it has the advantage of giving clients a more specific reason why they cannot get a snapshot format if the format they have chosen is disabled.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4a42f61..7068db2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5174,10 +5174,10 @@ sub git_snapshot {
 		die_error(400, "Invalid snapshot format parameter");
 	} elsif (!exists($known_snapshot_formats{$format})) {
 		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");
+	} elsif (!grep($_ eq $format, @snapshot_fmts)) {
+		die_error(403, "Unsupported snapshot format");
 	}
 
 	if (!defined $hash) {
-- 
1.6.4
Previous: Sam Vilain
Message 5 of 5 in “gitweb: make suspenders more useful”
  1. 1/3 gitweb: make suspenders more usefulMark Rada, Aug 23, 2009
  2. Sam VilainAug 23, 2009
  3. Mark RadaAug 23, 2009
  4. Sam VilainAug 23, 2009
  5. 1/3 gitweb: improve snapshot error handlingMark Rada, Aug 24, 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.