gitweb: Fix fixed string (non-regexp) project search
Use $search_regexp, where regex metacharacters are quoted, for searching projects list, rather than $searchtext, which contains original search term. Reported-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jakub Narebski committed
Mar 2, 2012 at 23:34 UTC
e65ceb61cd7d3fabedea8cb545f8c210b48552d4
1 file changed
+8
-8
gitweb/gitweb.perl
+8
-8
@@ -2905,10 +2905,10 @@ sub filter_forks_from_projects_list {
2905
sub search_projects_list {
2906
my ($projlist, %opts) = @_;
2907
my $tagfilter = $opts{'tagfilter'};
2908
- my $searchtext = $opts{'searchtext'};
2908
+ my $search_re = $opts{'search_regexp'};
2909
2910
return @$projlist
2911
- unless ($tagfilter || $searchtext);
2911
+ unless ($tagfilter || $search_re);
2912
2913
my @projects;
2914
PROJECT:
@@ -2920,10 +2920,10 @@ sub search_projects_list {
2920
grep { lc($_) eq lc($tagfilter) } keys %{$pr->{'ctags'}};
2921
}
2922
2923
- if ($searchtext) {
2923
+ if ($search_re) {
2924
next unless
2925
- $pr->{'path'} =~ /$searchtext/ ||
2926
- $pr->{'descr_long'} =~ /$searchtext/;
2925
+ $pr->{'path'} =~ /$search_re/ ||
2926
+ $pr->{'descr_long'} =~ /$search_re/;
2927
}
2928
2929
push @projects, $pr;
@@ -5089,7 +5089,7 @@ sub git_project_list_body {
5089
my $show_ctags = gitweb_check_feature('ctags');
5090
my $tagfilter = $show_ctags ? $cgi->param('by_tag') : undef;
5091
$check_forks = undef
5092
- if ($tagfilter || $searchtext);
5092
+ if ($tagfilter || $search_regexp);
5093
5094
# filtering out forks before filling info allows to do less work
5095
@projects = filter_forks_from_projects_list(\@projects)
@@ -5097,9 +5097,9 @@ sub git_project_list_body {
5097
@projects = fill_project_list_info(\@projects);
5098
# searching projects require filling to be run before it
5099
@projects = search_projects_list(\@projects,
5100
- 'searchtext' => $searchtext,
5100
+ 'search_regexp' => $search_regexp,
5101
'tagfilter' => $tagfilter)
5102
- if ($tagfilter || $searchtext);
5102
+ if ($tagfilter || $search_regexp);
5103
5104
$order ||= $default_projects_order;
5105
$from = 0 unless defined $from;