From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] gitweb: Avoid "Use of uninitialized value" errors (written to logs)
Date: Sat, 12 May 2007 01:35:29 +0200 [thread overview]
Message-ID: <200705120135.30150.jnareb@gmail.com> (raw)
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
next reply other threads:[~2007-05-12 0:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-11 23:35 Jakub Narebski [this message]
2007-05-12 1:06 ` [PATCH] gitweb: Avoid "Use of uninitialized value" errors (written to logs) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200705120135.30150.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).