@@ -458,8 +458,8 @@ sub filter_snapshot_fmts {
458
458
@fmts = map {
459
459
exists $known_snapshot_format_aliases {$_ } ?
460
460
$known_snapshot_format_aliases {$_ } : $_ } @fmts ;
461
- @fmts = grep ( exists $known_snapshot_formats { $_ }, @fmts );
462
-
461
+ @fmts = grep {
462
+ exists $known_snapshot_formats { $_ } } @fmts ;
463
463
}
464
464
465
465
our $GITWEB_CONFIG = $ENV {' GITWEB_CONFIG' } || " ++GITWEB_CONFIG++" ;
@@ -690,9 +690,10 @@ sub evaluate_path_info {
690
690
# format key itself, with a prepended dot
691
691
while (my ($fmt , $opt ) = each %known_snapshot_formats ) {
692
692
my $hash = $refname ;
693
- my $sfx ;
694
- $hash =~ s / (\Q $opt->{'suffix'}\E |\Q .$fmt\E )$// ;
695
- next unless $sfx = $1 ;
693
+ unless ($hash =~ s / (\Q $opt->{'suffix'}\E |\Q .$fmt\E )$// ) {
694
+ next ;
695
+ }
696
+ my $sfx = $1 ;
696
697
# a valid suffix was found, so set the snapshot format
697
698
# and reset the hash parameter
698
699
$input_params {' snapshot_format' } = $fmt ;
@@ -828,7 +829,7 @@ sub evaluate_path_info {
828
829
if (!defined ($actions {$action })) {
829
830
die_error(400, " Unknown action" );
830
831
}
831
- if ($action !~ m / ^(opml|project_list|project_index)$ / &&
832
+ if ($action !~ m / ^(?: opml|project_list|project_index)$ / &&
832
833
!$project ) {
833
834
die_error(400, " Project needed" );
834
835
}
@@ -1839,7 +1840,7 @@ sub git_cmd {
1839
1840
# Try to avoid using this function wherever possible.
1840
1841
sub quote_command {
1841
1842
return join (' ' ,
1842
- map ( { my $a = $_ ; $a =~ s / (['!])/ '\\ $1 '/ g ; " '$a '" } @_ ) );
1843
+ map { my $a = $_ ; $a =~ s / (['!])/ '\\ $1 '/ g ; " '$a '" } @_ );
1843
1844
}
1844
1845
1845
1846
# get HEAD ref of given project as hash
@@ -2051,7 +2052,7 @@ sub git_get_project_description {
2051
2052
my $path = shift ;
2052
2053
2053
2054
$git_dir = " $projectroot /$path " ;
2054
- open my $fd , " $git_dir /description"
2055
+ open my $fd , ' < ' , " $git_dir /description"
2055
2056
or return git_get_project_config(' description' );
2056
2057
my $descr = <$fd >;
2057
2058
close $fd ;
@@ -2066,18 +2067,17 @@ sub git_get_project_ctags {
2066
2067
my $ctags = {};
2067
2068
2068
2069
$git_dir = " $projectroot /$path " ;
2069
- unless (opendir D, " $git_dir /ctags" ) {
2070
- return $ctags ;
2071
- }
2072
- foreach (grep { -f $_ } map { " $git_dir /ctags/$_ " } readdir (D)) {
2073
- open CT, $_ or next ;
2074
- my $val = <CT>;
2070
+ opendir my $dh , " $git_dir /ctags"
2071
+ or return $ctags ;
2072
+ foreach (grep { -f $_ } map { " $git_dir /ctags/$_ " } readdir ($dh )) {
2073
+ open my $ct , ' <' , $_ or next ;
2074
+ my $val = <$ct >;
2075
2075
chomp $val ;
2076
- close CT ;
2076
+ close $ct ;
2077
2077
my $ctag = $_ ; $ctag =~ s # .*/## ;
2078
2078
$ctags -> {$ctag } = $val ;
2079
2079
}
2080
- closedir D ;
2080
+ closedir $dh ;
2081
2081
$ctags ;
2082
2082
}
2083
2083
@@ -2130,7 +2130,7 @@ sub git_get_project_url_list {
2130
2130
my $path = shift ;
2131
2131
2132
2132
$git_dir = " $projectroot /$path " ;
2133
- open my $fd , " $git_dir /cloneurl"
2133
+ open my $fd , ' < ' , " $git_dir /cloneurl"
2134
2134
or return wantarray ?
2135
2135
@{ config_to_multi(git_get_project_config(' url' )) } :
2136
2136
config_to_multi(git_get_project_config(' url' ));
@@ -2188,7 +2188,7 @@ sub git_get_projects_list {
2188
2188
# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
2189
2189
# 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
2190
2190
my %paths ;
2191
- open my ( $fd ) , $projects_list or return ;
2191
+ open my $fd , ' < ' , $projects_list or return ;
2192
2192
PROJECT:
2193
2193
while (my $line = <$fd >) {
2194
2194
chomp $line ;
@@ -2251,7 +2251,7 @@ sub git_get_project_list_from_file {
2251
2251
# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
2252
2252
# 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
2253
2253
if (-f $projects_list ) {
2254
- open (my $fd , $projects_list );
2254
+ open (my $fd , ' < ' , $projects_list );
2255
2255
while (my $line = <$fd >) {
2256
2256
chomp $line ;
2257
2257
my ($pr , $ow ) = split ' ' , $line ;
@@ -2805,18 +2805,18 @@ sub mimetype_guess_file {
2805
2805
-r $mimemap or return undef ;
2806
2806
2807
2807
my %mimemap ;
2808
- open (MIME , $mimemap ) or return undef ;
2809
- while (<MIME >) {
2808
+ open (my $mh , ' < ' , $mimemap ) or return undef ;
2809
+ while (<$mh >) {
2810
2810
next if m / ^#/ ; # skip comments
2811
- my ($mime , $exts ) = split (/ \t +/ );
2811
+ my ($mimetype , $exts ) = split (/ \t +/ );
2812
2812
if (defined $exts ) {
2813
2813
my @exts = split (/ \s +/ , $exts );
2814
2814
foreach my $ext (@exts ) {
2815
- $mimemap {$ext } = $mime ;
2815
+ $mimemap {$ext } = $mimetype ;
2816
2816
}
2817
2817
}
2818
2818
}
2819
- close (MIME );
2819
+ close ($mh );
2820
2820
2821
2821
$filename =~ / \. ([^.]*)$ / ;
2822
2822
return $mimemap {$1 };
@@ -3327,7 +3327,7 @@ sub git_get_link_target {
3327
3327
open my $fd , " -|" , git_cmd(), " cat-file" , " blob" , $hash
3328
3328
or return ;
3329
3329
{
3330
- local $/ ;
3330
+ local $/ = undef ;
3331
3331
$link_target = <$fd >;
3332
3332
}
3333
3333
close $fd
@@ -3340,10 +3340,7 @@ sub git_get_link_target {
3340
3340
# return target of link relative to top directory (top tree);
3341
3341
# return undef if it is not possible (including absolute links).
3342
3342
sub normalize_link_target {
3343
- my ($link_target , $basedir , $hash_base ) = @_ ;
3344
-
3345
- # we can normalize symlink target only if $hash_base is provided
3346
- return unless $hash_base ;
3343
+ my ($link_target , $basedir ) = @_ ;
3347
3344
3348
3345
# absolute symlinks (beginning with '/') cannot be normalized
3349
3346
return if (substr ($link_target , 0, 1) eq ' /' );
@@ -3399,7 +3396,7 @@ sub git_print_tree_entry {
3399
3396
if (S_ISLNK(oct $t -> {' mode' })) {
3400
3397
my $link_target = git_get_link_target($t -> {' hash' });
3401
3398
if ($link_target ) {
3402
- my $norm_target = normalize_link_target($link_target , $basedir , $hash_base );
3399
+ my $norm_target = normalize_link_target($link_target , $basedir );
3403
3400
if (defined $norm_target ) {
3404
3401
print " -> " .
3405
3402
$cgi -> a({-href => href(action => " object" , hash_base => $hash_base ,
@@ -3992,7 +3989,7 @@ sub fill_project_list_info {
3992
3989
($pname !~ / \/ $ / ) &&
3993
3990
(-d " $projectroot /$pname " )) {
3994
3991
$pr -> {' forks' } = " -d $projectroot /$pname " ;
3995
- } else {
3992
+ } else {
3996
3993
$pr -> {' forks' } = 0;
3997
3994
}
3998
3995
}
@@ -4802,11 +4799,10 @@ sub git_blob_plain {
4802
4799
-content_disposition =>
4803
4800
($sandbox ? ' attachment' : ' inline' )
4804
4801
. ' ; filename="' . $save_as . ' "' );
4805
- undef $/ ;
4802
+ local $/ = undef ;
4806
4803
binmode STDOUT , ' :raw' ;
4807
4804
print <$fd >;
4808
4805
binmode STDOUT , ' :utf8' ; # as set at the beginning of gitweb.cgi
4809
- $/ = " \n " ;
4810
4806
close $fd ;
4811
4807
}
4812
4808
@@ -4908,12 +4904,16 @@ sub git_tree {
4908
4904
}
4909
4905
}
4910
4906
die_error(404, " No such tree" ) unless defined ($hash );
4911
- $/ = " \0 " ;
4912
- open my $fd , " -|" , git_cmd(), " ls-tree" , ' -z' , $hash
4913
- or die_error(500, " Open git-ls-tree failed" );
4914
- my @entries = map { chomp ; $_ } <$fd >;
4915
- close $fd or die_error(404, " Reading tree failed" );
4916
- $/ = " \n " ;
4907
+
4908
+ my @entries = ();
4909
+ {
4910
+ local $/ = " \0 " ;
4911
+ open my $fd , " -|" , git_cmd(), " ls-tree" , ' -z' , $hash
4912
+ or die_error(500, " Open git-ls-tree failed" );
4913
+ @entries = map { chomp ; $_ } <$fd >;
4914
+ close $fd
4915
+ or die_error(404, " Reading tree failed" );
4916
+ }
4917
4917
4918
4918
my $refs = git_get_references();
4919
4919
my $ref = format_ref_marker($refs , $hash_base );
@@ -5808,7 +5808,7 @@ sub git_search {
5808
5808
5809
5809
print " <table class=\" pickaxe search\" >\n " ;
5810
5810
my $alternate = 1;
5811
- $/ = " \n " ;
5811
+ local $/ = " \n " ;
5812
5812
open my $fd , ' -|' , git_cmd(), ' --no-pager' , ' log' , @diff_opts ,
5813
5813
' --pretty=format:%H' , ' --no-abbrev' , ' --raw' , " -S$searchtext " ,
5814
5814
($search_use_regexp ? ' --pickaxe-regex' : ());
@@ -5878,7 +5878,7 @@ sub git_search {
5878
5878
print " <table class=\" grep_search\" >\n " ;
5879
5879
my $alternate = 1;
5880
5880
my $matches = 0;
5881
- $/ = " \n " ;
5881
+ local $/ = " \n " ;
5882
5882
open my $fd , " -|" , git_cmd(), ' grep' , ' -n' ,
5883
5883
$search_use_regexp ? (' -E' , ' -i' ) : ' -F' ,
5884
5884
$searchtext , $co {' tree' };
@@ -6281,7 +6281,7 @@ sub git_feed {
6281
6281
# end of feed
6282
6282
if ($format eq ' rss' ) {
6283
6283
print " </channel>\n </rss>\n " ;
6284
- } elsif ($format eq ' atom' ) {
6284
+ } elsif ($format eq ' atom' ) {
6285
6285
print " </feed>\n " ;
6286
6286
}
6287
6287
}
0 commit comments