git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [laroche@redhat.com: gitweb.cgi]
@ 2006-09-25 16:19 Florian La Roche
  2006-09-25 16:32 ` Jakub Narebski
  0 siblings, 1 reply; 2+ messages in thread
From: Florian La Roche @ 2006-09-25 16:19 UTC (permalink / raw)
  To: git

Hello git crew,

I'm not a big perl prorammer, but the following removes perl
warnings about accessing undefined vars.

regards,

Florian La Roche


--- gitweb/gitweb.perl
+++ gitweb/gitweb.perl
@@ -427,7 +427,9 @@ sub esc_html {
 	my $str = shift;
 	$str = decode("utf8", $str, Encode::FB_DEFAULT);
 	$str = escapeHTML($str);
-	$str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
+	if (defined $str) {
+		$str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
+	}
 	return $str;
 }
 
@@ -2860,10 +2819,14 @@ sub git_log {
 		my $ref = format_ref_marker($refs, $commit);
 		my %co = parse_commit($commit);
 		next if !%co;
+		my $esc_title = $co{'title'};
+		if (defined $esc_title) {
+			$esc_title = esc_html($esc_title);
+		}
 		my %ad = parse_date($co{'author_epoch'});
 		git_print_header_div('commit',
 		               "<span class=\"age\">$co{'age_string'}</span>" .
-		               esc_html($co{'title'}) . $ref,
+		               $esc_title . $ref,
 		               $commit);
 		print "<div class=\"title_text\">\n" .
 		      "<div class=\"log_link\">\n" .

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

* Re: [laroche@redhat.com: gitweb.cgi]
  2006-09-25 16:19 [laroche@redhat.com: gitweb.cgi] Florian La Roche
@ 2006-09-25 16:32 ` Jakub Narebski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Narebski @ 2006-09-25 16:32 UTC (permalink / raw)
  To: git

Florian La Roche wrote:

> Hello git crew,
> 
> I'm not a big perl prorammer, but the following removes perl
> warnings about accessing undefined vars.
[...] 
> --- gitweb/gitweb.perl
> +++ gitweb/gitweb.perl
> @@ -427,7 +427,9 @@ sub esc_html {
>       my $str = shift;
>       $str = decode("utf8", $str, Encode::FB_DEFAULT);
>       $str = escapeHTML($str);
> -     $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
> +     if (defined $str) {
> +             $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
> +     }
>       return $str;
>  }
> 
It would be better to just use

        my $str = shift;
        return '' unless defined $str;

and neither your change in esc_html, nor the change below should be needed. 
By the way, commit without title? But it would be better if correct it, to
set $co{'title'} to an empty string, either in git_log or in parse_commit.
 
> @@ -2860,10 +2819,14 @@ sub git_log {
>               my $ref = format_ref_marker($refs, $commit);
>               my %co = parse_commit($commit);
>               next if !%co;
> +             my $esc_title = $co{'title'};
> +             if (defined $esc_title) {
> +                     $esc_title = esc_html($esc_title);
> +             }
>               my %ad = parse_date($co{'author_epoch'});
>               git_print_header_div('commit',
>                              "<span class=\"age\">$co{'age_string'}</span>" .
> -                            esc_html($co{'title'}) . $ref,
> +                            $esc_title . $ref,
>                              $commit);
>               print "<div class=\"title_text\">\n" .
>                     "<div class=\"log_link\">\n" .

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

end of thread, other threads:[~2006-09-25 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-25 16:19 [laroche@redhat.com: gitweb.cgi] Florian La Roche
2006-09-25 16:32 ` Jakub Narebski

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).