@matheusbsbs / matheus-bagliano / commits / 4229aa5141
Fork 0

gitweb: Allow arbitrary strings to be dug with pickaxe

Currently, there are rather draconian restrictions on the strings accepted by the pickaxe search, which degrades its usefulness for digging in code significantly. This patch remedies mentioned limitation. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>

Petr Baudis committed May 17, 2007 at 04:30 UTC 4229aa5141b5d7716d283fa8625209b59398d7ba
1 file changed +4 -2
gitweb/gitweb.perl
+4 -2
@@ -399,7 +399,7 @@ if (defined $searchtype) {
399 our $searchtext = $cgi->param('s');
400 our $search_regexp;
401 if (defined $searchtext) {
402 - if ($searchtype ne 'grep' and $searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
402 + if ($searchtype ne 'grep' and $searchtype ne 'pickaxe' and $searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
403 die_error(undef, "Invalid search parameter");
404 }
405 if (length($searchtext) < 2) {
@@ -4725,8 +4725,10 @@ sub git_search {
4725 my $alternate = 1;
4726 $/ = "\n";
4727 my $git_command = git_cmd_str();
4728 + my $searchqtext = $searchtext;
4729 + $searchqtext =~ s/'/'\\''/;
4730 open my $fd, "-|", "$git_command rev-list $hash | " .
4729 - "$git_command diff-tree -r --stdin -S\'$searchtext\'";
4731 + "$git_command diff-tree -r --stdin -S\'$searchqtext\'";
4732 undef %co;
4733 my @files;
4734 while (my $line = <$fd>) {