{"thread":{"id":"8174","subject":"[PATCH] gitweb: Separate search regexp from search text","startedAt":"2007-05-15T23:56:10Z","lastAt":"2007-05-15T23:56:10Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"42268","messageId":"200705160156.10866.jnareb@gmail.com","threadId":"8174","inReplyTo":null,"subject":"[PATCH] gitweb: Separate search regexp from search text","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-05-15T23:56:10Z","receivedAt":"2007-05-15T23:56:10Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Separate search text, which is saved in $searchtext global variable,\nand is used in links, as default value for the textfield in search\nform, and for pickaxe search, from search regexp, which is saved in\n$search_regexp global variable, and is used as parameter to --grep,\n--committer or --author options to git-rev-list, and for searching\ncommit body in gitweb.  For now $search_regexp is unconditionallt\nequal to quotemeta($searchtext), meaning that we always search for\nfixed string.\n\nThis fixes bug where 'next page' links for 'search' view didn't work\nfor searchtext containing quotable characters, like `@'.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThere was similar patch; bit of bandaid (without commit message IIRC),\nbut I cannot find it to add Originally-by:/Suggested-by: acknowledgement\nheader, not Noticed-by: header...\n\n gitweb/gitweb.perl |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a13043d..549e027 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -365,6 +365,7 @@ if (defined $page) {\n }\n \n our $searchtext = $cgi->param('s');\n+our $search_regexp;\n if (defined $searchtext) {\n \tif ($searchtext =~ m/[^a-zA-Z0-9_\\.\\/\\-\\+\\:\\@ ]/) {\n \t\tdie_error(undef, \"Invalid search parameter\");\n@@ -372,7 +373,7 @@ if (defined $searchtext) {\n \tif (length($searchtext) < 2) {\n \t\tdie_error(undef, \"At least two characters are required for search parameter\");\n \t}\n-\t$searchtext = quotemeta $searchtext;\n+\t$search_regexp = quotemeta $searchtext;\n }\n \n our $searchtype = $cgi->param('st');\n@@ -3244,7 +3245,7 @@ sub git_search_grep_body {\n \t\t\t       esc_html(chop_str($co{'title'}, 50)) . \"<br/>\");\n \t\tmy $comment = $co{'comment'};\n \t\tforeach my $line (@$comment) {\n-\t\t\tif ($line =~ m/^(.*)($searchtext)(.*)$/i) {\n+\t\t\tif ($line =~ m/^(.*)($search_regexp)(.*)$/i) {\n \t\t\t\tmy $lead = esc_html($1) || \"\";\n \t\t\t\t$lead = chop_str($lead, 30, 10);\n \t\t\t\tmy $match = esc_html($2) || \"\";\n@@ -4626,7 +4627,7 @@ sub git_search {\n \t\t} elsif ($searchtype eq 'committer') {\n \t\t\t$greptype = \"--committer=\";\n \t\t}\n-\t\t$greptype .= $searchtext;\n+\t\t$greptype .= $search_regexp;\n \t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);\n \n \t\tmy $paging_nav = '';\n-- \n1.5.1.4\n"}]}