summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorJakub Narebski <jnareb@gmail.com>2007-07-25 01:19:58 +0200
committerJunio C Hamano <gitster@pobox.com>2007-07-24 17:26:04 -0700
commit3473e7df5f8c7f8dc3e2c3f2fdc99a1d1a719c16 (patch)
tree0f3e50085558de54b9af98150befde10501101d0 /gitweb
parent93c22eeb30d2f43fc1e7a397e71f9bf8fb767962 (diff)
downloadgit-3473e7df5f8c7f8dc3e2c3f2fdc99a1d1a719c16.tar.gz
gitweb: More detailed error messages for snapshot format
Improve error messages for snapshot format in git_snapshot: distinguish between situation where snapshots are turned off, where snapshot format ('sf') parameter is invalid, where given snapshot format does not exist in %known_snapshot_formats hash, and where gitweb was given unsupported snapshot format. While at it, use first from all supported snapshots format as default, if no snapshot format was provided. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl13
1 files changed, 10 insertions, 3 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index fdfce311fd..0acd0cafb3 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4317,9 +4317,16 @@ sub git_snapshot {
@supported_fmts = filter_snapshot_fmts(@supported_fmts);
my $format = $cgi->param('sf');
- unless ($format =~ m/[a-z0-9]+/
- && exists($known_snapshot_formats{$format})
- && grep($_ eq $format, @supported_fmts)) {
+ if (!@supported_fmts) {
+ die_error('403 Permission denied', "Permission denied");
+ }
+ # default to first supported snapshot format
+ $format ||= $supported_fmts[0];
+ if ($format !~ m/^[a-z0-9]+$/) {
+ die_error(undef, "Invalid snapshot format parameter");
+ } elsif (!exists($known_snapshot_formats{$format})) {
+ die_error(undef, "Unknown snapshot format");
+ } elsif (!grep($_ eq $format, @supported_fmts)) {
die_error(undef, "Unsupported snapshot format");
}