{"thread":{"id":"8186","subject":"[PATCH] gitweb: Allow arbitrary strings to be dug with pickaxe","startedAt":"2007-05-17T02:30:42Z","lastAt":"2007-05-17T02:30:42Z","messageCount":1,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"42362","messageId":"20070517023042.19611.59572.stgit@rover","threadId":"8186","inReplyTo":null,"subject":"[PATCH] gitweb: Allow arbitrary strings to be dug with pickaxe","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-05-17T02:30:42Z","receivedAt":"2007-05-17T02:30:42Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Currently, there are rather draconian restrictions on the strings accepted\nby the pickaxe search, which degrades its usefulness for digging in code\nsignificantly. This patch remedies mentioned limitation.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n gitweb/gitweb.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 4a1a423..8dc009a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -404,7 +404,7 @@ if (defined $searchtype) {\n our $searchtext = $cgi->param('s');\n our $search_regexp;\n if (defined $searchtext) {\n-\tif ($searchtype ne 'grep' and $searchtext =~ m/[^a-zA-Z0-9_\\.\\/\\-\\+\\:\\@ ]/) {\n+\tif ($searchtype ne 'grep' and $searchtype ne 'pickaxe' and $searchtext =~ m/[^a-zA-Z0-9_\\.\\/\\-\\+\\:\\@ ]/) {\n \t\tdie_error(undef, \"Invalid search parameter\");\n \t}\n \tif (length($searchtext) < 2) {\n@@ -4794,8 +4794,10 @@ sub git_search {\n \t\tmy $alternate = 1;\n \t\t$/ = \"\\n\";\n \t\tmy $git_command = git_cmd_str();\n+\t\tmy $searchqtext = $searchtext;\n+\t\t$searchqtext =~ s/'/'\\\\''/;\n \t\topen my $fd, \"-|\", \"$git_command rev-list $hash | \" .\n-\t\t\t\"$git_command diff-tree -r --stdin -S\\'$searchtext\\'\";\n+\t\t\t\"$git_command diff-tree -r --stdin -S\\'$searchqtext\\'\";\n \t\tundef %co;\n \t\tmy @files;\n \t\twhile (my $line = <$fd>) {\n"}]}