Skip to content

Commit

Permalink
gitweb: fix 'Use of uninitialized value' error in href()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Giuseppe Bilotta authored and Junio C Hamano committed Aug 4, 2009
1 parent 6639ffc commit b7da721
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -940,10 +940,13 @@ sub href {
if (defined $params{'hash_parent_base'}) {
$href .= esc_url($params{'hash_parent_base'});
# skip the file_parent if it's the same as the file_name
delete $params{'file_parent'} if $params{'file_parent'} eq $params{'file_name'};
if (defined $params{'file_parent'} && $params{'file_parent'} !~ /\.\./) {
$href .= ":/".esc_url($params{'file_parent'});
delete $params{'file_parent'};
if (defined $params{'file_parent'}) {
if (defined $params{'file_name'} && $params{'file_parent'} eq $params{'file_name'}) {
delete $params{'file_parent'};
} elsif ($params{'file_parent'} !~ /\.\./) {
$href .= ":/".esc_url($params{'file_parent'});
delete $params{'file_parent'};
}
}
$href .= "..";
delete $params{'hash_parent'};
Expand Down

0 comments on commit b7da721

Please sign in to comment.