@matheusbsbs / matheus-bagliano / commits / b7da721f02
Fork 0

gitweb: fix 'Use of uninitialized value' error in href()

Equality between file_parent and file_name was being checked without a preliminary check for existence of the parameters. Fix by wrapping the equality check in appropriate if (defined ...), rearranging the lines to prevent excessive length. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Giuseppe Bilotta committed Jul 31, 2009 at 08:48 UTC b7da721f02638083cc3debfd9ae7221d76a96b26
1 file changed +7 -4
gitweb/gitweb.perl
+7 -4
@@ -940,10 +940,13 @@ sub href {
940 if (defined $params{'hash_parent_base'}) {
941 $href .= esc_url($params{'hash_parent_base'});
942 # skip the file_parent if it's the same as the file_name
943 - delete $params{'file_parent'} if $params{'file_parent'} eq $params{'file_name'};
944 - if (defined $params{'file_parent'} && $params{'file_parent'} !~ /\.\./) {
945 - $href .= ":/".esc_url($params{'file_parent'});
946 - delete $params{'file_parent'};
943 + if (defined $params{'file_parent'}) {
944 + if (defined $params{'file_name'} && $params{'file_parent'} eq $params{'file_name'}) {
945 + delete $params{'file_parent'};
946 + } elsif ($params{'file_parent'} !~ /\.\./) {
947 + $href .= ":/".esc_url($params{'file_parent'});
948 + delete $params{'file_parent'};
949 + }
950 }
951 $href .= "..";
952 delete $params{'hash_parent'};