git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH (BUGFIX)] gitweb: Fix fixed string (non-regexp) project search

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 3, 2012, 00:08 UTC
Message-ID
<7vwr72a6m6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201203022334.25544.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
Show 16 quoted lines
> 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>
> ---
> I think this bug was here from the very beginning of adding project
> search, i.e. from  v1.6.0.2-446-g0d1d154 (gitweb: Support for simple
> project search form, 2008-10-03)  which was present since 1.6.1
>
> On Fri, 2 Mar 2012, Ramsay Jones wrote:
> 
>> This patch solves the problem for me when using a regex search
>> (re checkbox checked), but *not* for a non-regex search.
>> 

This patch depends on the more recent changes than the regexp fix, no? I was hoping that we could merge the earlier fix for the regexp case to older maintenance tracks later, but if we were going to do so, we would want to do the same for a fix for fixed-string case.

I am fine with not to worrying too much about older maintenance tracks, and applying this directly to 'master', but just wanted to see what your preference is.

Thanks.
Show 65 quoted lines
>> If you have a leading '*' or '+', in the non-regex case, then you
>> still get the above complaint (and xml error page etc.), although
>> the line number has changed slightly from that given above.
>
> Ramsay, please provide those line number in the future, together with
> line and if possible some context.
>
> The line is different because it is different bug: this is about not
> using quotemeta'ed string for search for fixed-string search.
>
>  gitweb/gitweb.perl |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 22ad279..7398be1 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -3072,16 +3072,16 @@ sub filter_forks_from_projects_list {
>  # for 'descr_long' and 'ctags' to be filled
>  sub search_projects_list {
>  	my ($projlist, %opts) = @_;
> -	my $tagfilter  = $opts{'tagfilter'};
> -	my $searchtext = $opts{'searchtext'};
> +	my $tagfilter = $opts{'tagfilter'};
> +	my $search_re = $opts{'search_regexp'};
>  
>  	return @$projlist
> -		unless ($tagfilter || $searchtext);
> +		unless ($tagfilter || $search_re);
>  
>  	# searching projects require filling to be run before it;
>  	fill_project_list_info($projlist,
> -	                       $tagfilter  ? 'ctags' : (),
> -	                       $searchtext ? ('path', 'descr') : ());
> +	                       $tagfilter ? 'ctags' : (),
> +	                       $search_re ? ('path', 'descr') : ());
>  	my @projects;
>   PROJECT:
>  	foreach my $pr (@$projlist) {
> @@ -3092,10 +3092,10 @@ sub search_projects_list {
>  				grep { lc($_) eq lc($tagfilter) } keys %{$pr->{'ctags'}};
>  		}
>  
> -		if ($searchtext) {
> +		if ($search_re) {
>  			next unless
> -				$pr->{'path'} =~ /$searchtext/ ||
> -				$pr->{'descr_long'} =~ /$searchtext/;
> +				$pr->{'path'} =~ /$search_re/ ||
> +				$pr->{'descr_long'} =~ /$search_re/;
>  		}
>  
>  		push @projects, $pr;
> @@ -5498,9 +5498,9 @@ sub git_project_list_body {
>  		if ($check_forks);
>  	# search_projects_list pre-fills required info
>  	@projects = search_projects_list(\@projects,
> -	                                 'searchtext' => $searchtext,
> -	                                 'tagfilter'  => $tagfilter)
> -		if ($tagfilter || $searchtext);
> +	                                 'search_regexp' => $search_regexp,
> +	                                 'tagfilter' => $tagfilter)
> +		if ($tagfilter || $search_regexp);
>  	# fill the rest
>  	@projects = fill_project_list_info(\@projects);
Previous: Jakub NarebskiNext: Jakub Narebski
Message 6 of 18 in “gitweb: Handle invalid regexp in regexp search”
  1. gitweb: Handle invalid regexp in regexp searchJakub Narebski, Feb 28, 2012
  2. Junio C HamanoFeb 28, 2012
  3. Jakub NarebskiFeb 29, 2012
  4. Ramsay JonesMar 2, 2012
  5. gitweb: Fix fixed string (non-regexp) project searchJakub Narebski, Mar 2, 2012
  6. Junio C HamanoMar 3, 2012
  7. Jakub NarebskiMar 3, 2012
  8. gitweb: Fix fixed string (non-regexp) project searchJakub Narebski, Mar 4, 2012
  9. Junio C HamanoMar 5, 2012
  10. Jakub NarebskiMar 5, 2012
  11. Junio C HamanoMar 5, 2012
  12. Junio C HamanoMar 5, 2012
  13. Jakub NarebskiMar 6, 2012
  14. Jakub NarebskiMar 4, 2012
  15. Junio C HamanoMar 4, 2012
  16. Jakub NarebskiMar 5, 2012
  17. Ramsay JonesMar 5, 2012
  18. Jakub NarebskiMar 6, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.