Merge branch 'jn/maint-do-not-match-with-unsanitized-searchtext'

By Jakub Narebski
* jn/maint-do-not-match-with-unsanitized-searchtext:
  gitweb: Fix fixed string (non-regexp) project search

Conflicts:
	gitweb/gitweb.perl
This commit is contained in:
Junio C Hamano 2012-03-08 13:04:49 -08:00
commit aa145bf6f1

View File

@ -3073,15 +3073,15 @@ sub filter_forks_from_projects_list {
sub search_projects_list { sub search_projects_list {
my ($projlist, %opts) = @_; my ($projlist, %opts) = @_;
my $tagfilter = $opts{'tagfilter'}; my $tagfilter = $opts{'tagfilter'};
my $searchtext = $opts{'searchtext'}; my $search_re = $opts{'search_regexp'};
return @$projlist return @$projlist
unless ($tagfilter || $searchtext); unless ($tagfilter || $search_re);
# searching projects require filling to be run before it; # searching projects require filling to be run before it;
fill_project_list_info($projlist, fill_project_list_info($projlist,
$tagfilter ? 'ctags' : (), $tagfilter ? 'ctags' : (),
$searchtext ? ('path', 'descr') : ()); $search_re ? ('path', 'descr') : ());
my @projects; my @projects;
PROJECT: PROJECT:
foreach my $pr (@$projlist) { foreach my $pr (@$projlist) {
@ -3092,10 +3092,10 @@ sub search_projects_list {
grep { lc($_) eq lc($tagfilter) } keys %{$pr->{'ctags'}}; grep { lc($_) eq lc($tagfilter) } keys %{$pr->{'ctags'}};
} }
if ($searchtext) { if ($search_re) {
next unless next unless
$pr->{'path'} =~ /$searchtext/ || $pr->{'path'} =~ /$search_re/ ||
$pr->{'descr_long'} =~ /$searchtext/; $pr->{'descr_long'} =~ /$search_re/;
} }
push @projects, $pr; push @projects, $pr;
@ -5484,16 +5484,16 @@ sub git_project_list_body {
my $show_ctags = gitweb_check_feature('ctags'); my $show_ctags = gitweb_check_feature('ctags');
my $tagfilter = $show_ctags ? $input_params{'ctag'} : undef; my $tagfilter = $show_ctags ? $input_params{'ctag'} : undef;
$check_forks = undef $check_forks = undef
if ($tagfilter || $searchtext); if ($tagfilter || $search_regexp);
# filtering out forks before filling info allows to do less work # filtering out forks before filling info allows to do less work
@projects = filter_forks_from_projects_list(\@projects) @projects = filter_forks_from_projects_list(\@projects)
if ($check_forks); if ($check_forks);
# search_projects_list pre-fills required info # search_projects_list pre-fills required info
@projects = search_projects_list(\@projects, @projects = search_projects_list(\@projects,
'searchtext' => $searchtext, 'search_regexp' => $search_regexp,
'tagfilter' => $tagfilter) 'tagfilter' => $tagfilter)
if ($tagfilter || $searchtext); if ($tagfilter || $search_regexp);
# fill the rest # fill the rest
@projects = fill_project_list_info(\@projects); @projects = fill_project_list_info(\@projects);