Skip to content

Commit b7da721

Browse files
Oblomovgitster
authored andcommitted
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 <[email protected]> Acked-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6639ffc commit b7da721

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gitweb/gitweb.perl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,13 @@ sub href {
940940
if (defined $params{'hash_parent_base'}) {
941941
$href .= esc_url($params{'hash_parent_base'});
942942
# 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+
}
947950
}
948951
$href .= "..";
949952
delete $params{'hash_parent'};

0 commit comments

Comments
 (0)