]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Allow arbitrary strings to be dug with pickaxe
authorPetr Baudis <redacted>
Thu, 17 May 2007 02:30:42 +0000 (04:30 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:11 +0000 (00:07 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 5363d3ee706021b37d071045997b5f4d50720fc21ed7ad0a689b75d3f542a4e2..c0905d182e6805771e75b3dd6daeee7f5621c7d87c8227e7086dcd5b48ac70ae 100755 (executable)
@@ -400,7 +400,7 @@ if (defined $searchtype) {
 our $searchtext = $cgi->param('s');
 our $search_regexp;
 if (defined $searchtext) {
-       if ($searchtype ne 'grep' and $searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
+       if ($searchtype ne 'grep' and $searchtype ne 'pickaxe' and $searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
                die_error(undef, "Invalid search parameter");
        }
        if (length($searchtext) < 2) {
@@ -4726,8 +4726,10 @@ sub git_search {
                my $alternate = 1;
                $/ = "\n";
                my $git_command = git_cmd_str();
+               my $searchqtext = $searchtext;
+               $searchqtext =~ s/'/'\\''/;
                open my $fd, "-|", "$git_command rev-list $hash | " .
-                       "$git_command diff-tree -r --stdin -S\'$searchtext\'";
+                       "$git_command diff-tree -r --stdin -S\'$searchqtext\'";
                undef %co;
                my @files;
                while (my $line = <$fd>) {
This page took 0.322767 seconds and 4 git commands to generate.