git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Avoid "Use of uninitialized value" errors (written to logs)
@ 2007-05-11 23:35 Jakub Narebski
  2007-05-12  1:06 ` Junio C Hamano
  2007-05-12 10:42 ` [PATCH] gitweb: Test if $from_id and $to_id are defined before comparison Jakub Narebski
  0 siblings, 2 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-05-11 23:35 UTC (permalink / raw)
  To: git

Try to avoid "Use of uninitialized value ..." errors, due to 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.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is a bit of "bandaid" patch, as if possible the callers should
be corrected, and should check if there is something to pass along.

 gitweb/gitweb.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 21864c6..afa0056 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -594,6 +594,9 @@ sub esc_html ($;%) {
 	my $str = shift;
 	my %opts = @_;
 
+	# empty or undefined
+	return $str unless $str;
+
 	$str = decode_utf8($str);
 	$str = $cgi->escapeHTML($str);
 	if ($opts{'-nbsp'}) {
@@ -1059,6 +1062,7 @@ sub git_get_hash_by_path {
 		or die_error(undef, "Open git-ls-tree failed");
 	my $line = <$fd>;
 	close $fd or return undef;
+	$line or return undef;
 
 	#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
 	$line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
@@ -1377,7 +1381,7 @@ sub parse_commit_text {
 	pop @commit_lines; # Remove '\0'
 
 	my $header = shift @commit_lines;
-	if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
+	if (!defined $header || $header !~ m/^[0-9a-fA-F]{40}/) {
 		return;
 	}
 	($co{'id'}, my @parents) = split ' ', $header;
-- 
1.5.1.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-05-13 23:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-11 23:35 [PATCH] gitweb: Avoid "Use of uninitialized value" errors (written to logs) Jakub Narebski
2007-05-12  1:06 ` Junio C Hamano
2007-05-12 19:16   ` [PATCH (amend)] gitweb: Check if requested object exists Jakub Narebski
2007-05-13 10:39     ` [PATCH] gitweb: Fix "Use of unitialized value" warnings in empty repository Jakub Narebski
2007-05-13 19:12     ` [PATCH (amend)] gitweb: Check if requested object exists Junio C Hamano
2007-05-12 10:42 ` [PATCH] gitweb: Test if $from_id and $to_id are defined before comparison Jakub Narebski
2007-05-12 19:27   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).