зеркало из https://github.com/microsoft/git.git
gitweb: Check if requested object exists
Try to avoid "Use of uninitialized value ..." errors caused by bad revision, incorrect filename, wrong object id, bad file etc. (wrong value of 'h', 'hb', 'f', etc. parameters). This avoids polluting web server errors log. Correct git_get_hash_by_path and parse_commit_text (and, in turn, parse_commit) to return undef if object does not exist. Check in git_tag if requested tag exists. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
a2983cb740
Коммит
198a2a8a69
|
@ -1060,6 +1060,11 @@ sub git_get_hash_by_path {
|
|||
my $line = <$fd>;
|
||||
close $fd or return undef;
|
||||
|
||||
if (!defined $line) {
|
||||
# there is no tree or hash given by $path at $base
|
||||
return undef;
|
||||
}
|
||||
|
||||
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
|
||||
$line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
|
||||
if (defined $type && $type ne $2) {
|
||||
|
@ -1376,8 +1381,12 @@ sub parse_commit_text {
|
|||
|
||||
pop @commit_lines; # Remove '\0'
|
||||
|
||||
if (! @commit_lines) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $header = shift @commit_lines;
|
||||
if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
|
||||
if ($header !~ m/^[0-9a-fA-F]{40}/) {
|
||||
return;
|
||||
}
|
||||
($co{'id'}, my @parents) = split ' ', $header;
|
||||
|
@ -3409,6 +3418,11 @@ sub git_tag {
|
|||
git_header_html();
|
||||
git_print_page_nav('','', $head,undef,$head);
|
||||
my %tag = parse_tag($hash);
|
||||
|
||||
if (! %tag) {
|
||||
die_error(undef, "Unknown tag object");
|
||||
}
|
||||
|
||||
git_print_header_div('commit', esc_html($tag{'name'}), $hash);
|
||||
print "<div class=\"title_text\">\n" .
|
||||
"<table cellspacing=\"0\">\n" .
|
||||
|
|
Загрузка…
Ссылка в новой задаче