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 4, 2012, 23:08 UTC
Message-ID
<7vaa3w55i3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201203031156.00948.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> ....  The fix is about adding new code and should
> apply cleanly to 'maint' and even to older versions; the only trouble
> with older version might be whitespace issue related to refactoring
> code into subroutines.

OK, so the global $searchtext is what came from form submit from the end user, while the global $search_regexp is what the code should be using for matching throughout the program, prepared by eval-and-validate-params.

Here is a hand-ported version of your patch that should apply to 1.7.6.6; does it look sane?

 gitweb/gitweb.perl |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 50a835a..d1698b7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2905,10 +2905,10 @@ sub filter_forks_from_projects_list {
 sub search_projects_list {
 	my ($projlist, %opts) = @_;
 	my $tagfilter  = $opts{'tagfilter'};
-	my $searchtext = $opts{'searchtext'};
+	my $search_re = $opts{'search_regexp'};
 
 	return @$projlist
-		unless ($tagfilter || $searchtext);
+		unless ($tagfilter || $search_re);
 
 	my @projects;
  PROJECT:
@@ -2920,10 +2920,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;
@@ -5097,7 +5097,7 @@ sub git_project_list_body {
 	@projects = fill_project_list_info(\@projects);
 	# searching projects require filling to be run before it
 	@projects = search_projects_list(\@projects,
-	                                 'searchtext' => $searchtext,
+	                                 'search_regexp' => $search_regexp,
 	                                 'tagfilter'  => $tagfilter)
 		if ($tagfilter || $searchtext);
 
Previous: Jakub NarebskiNext: Jakub Narebski
Message 15 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.