# PullRequest: gitweb.perl: fix 'Use of uninitialized value $params{"action"} in string eq at gitweb.cgi line 1377'

2 messages from 2020-04-24 to 2020-04-25. Participants: Raphaël Gertz, Johannes Schindelin.
Thread: https://gitlist.dev/t/53309

## Raphaël Gertz, 2020-04-24 13:34

Subject: PullRequest: gitweb.perl: fix 'Use of uninitialized value $params{"action"} in string eq at gitweb.cgi line 1377'
Message-ID: <903700aa01abb139e9bf422835b26ca2@rapsys.eu>
URL: https://gitlist.dev/e/903700aa01abb139e9bf422835b26ca2%40rapsys.eu

```
Hi,

This is a small fix in gitweb/gitweb.perl script that I tried to get 
applied long ago.

The current gitweb.perl cgi script generate lots of warnings in the web 
server logs without reason by skipping defined test.

Pull request was done here against "maint" branch :
https://github.com/gitgitgadget/git/pull/617

Pull request was done here against "master" branch if required :
https://github.com/git/git/pull/767

The change patch is attached if required.

May you plz merge my change ?

Best regards

diff -urNp gitweb/gitweb.perl.orig gitweb/gitweb.perl
--- gitweb/gitweb.perl.orig	2019-11-14 07:39:24.244704744 +0100
+++ gitweb/gitweb.perl	2019-11-14 07:33:50.641602829 +0100
@@ -1374,7 +1374,7 @@ sub href {
 
 		# since we destructively absorb parameters, we keep this
 		# boolean that remembers if we're handling a snapshot
-		my $is_snapshot = $params{'action'} eq 'snapshot';
+		my $is_snapshot = defined $params{'action'} && $params{'action'} eq 'snapshot';
 
 		# Summary just uses the project path URL, any other action is
 		# added to the URL
@@ -5959,7 +5959,7 @@ sub git_history_body {
 		      $cgi->a({-href => href(action=>$ftype, hash_base=>$commit, file_name=>$file_name)}, $ftype) . " | " .
 		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff");
 
-		if ($ftype eq 'blob') {
+		if (defined $ftype && $ftype eq 'blob') {
 			print " | " .
 			      $cgi->a({-href => href(action=>"blob_plain", hash_base=>$commit, file_name=>$file_name)}, "raw");
 
diff -urNp gitweb/README.orig gitweb/README
--- gitweb/README.orig	2019-11-14 07:39:24.244704744 +0100
+++ gitweb/README	2019-11-14 07:33:50.641602829 +0100
@@ -66,5 +66,8 @@ AUTHORS
 Originally written by:
   Kay Sievers <kay.sievers@vrfy.org>
 
+Perl warning fix:
+  Raphaël Gertz <git@rapsys.eu>
+
 Any comment/question/concern to:
   Git mailing list <git@vger.kernel.org>

```

## Johannes Schindelin, 2020-04-25 13:46

Subject: Re: PullRequest: gitweb.perl: fix 'Use of uninitialized value $params{"action"} in string eq at gitweb.cgi line 1377'
Message-ID: <nycvar.QRO.7.76.6.2004251545140.18039@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.2004251545140.18039%40tvgsbejvaqbjf.bet
In-Reply-To: <903700aa01abb139e9bf422835b26ca2@rapsys.eu>

```
Hi Raphaël,

On Fri, 24 Apr 2020, Raphaël Gertz wrote:

> This is a small fix in gitweb/gitweb.perl script that I tried to get applied
> long ago.
>
> The current gitweb.perl cgi script generate lots of warnings in the web server
> logs without reason by skipping defined test.
>
> Pull request was done here against "maint" branch :
> https://github.com/gitgitgadget/git/pull/617

As pointed out by GitGitGadget's Welcome message at
https://github.com/git/git/pull/767#issuecomment-618976608, the idea is
that you submit the patches to the mailing list by adding a comment to the
PR that says `/submit`.

Ciao,
Johannes

```
