From: Jakub Narebski <jnareb@gmail.com>
To: "J.H." <warthog19@eaglescrag.net>
Cc: Olaf Hering <olaf@aepfle.de>,
Michael J Gruber <git@drmicha.warpmail.net>,
git@vger.kernel.org
Subject: [PATCH (backport for warthog9/gitweb.git)] gitweb: Separate search regexp from search text
Date: Thu, 30 Apr 2009 12:17:25 +0200 [thread overview]
Message-ID: <200904301217.27154.jnareb@gmail.com> (raw)
In-Reply-To: <49F8DEB4.40909@eaglescrag.net>
Separate search text, which is saved in $searchtext global variable,
and is used in links, as default value for the textfield in search
form, and for pickaxe search, from search regexp, which is saved in
$search_regexp global variable, and is used as parameter to --grep,
--committer or --author options to git-rev-list, and for searching
commit body in gitweb. For now $search_regexp is unconditionally
equal to quotemeta($searchtext), meaning that we always search for
fixed string.
This fixes bug where 'next page' links for 'search' view didn't work
for searchtext containing quotable characters, like `@'.
(manually cherry picked from 7e431ef9ab933d7ff899a999e40627ab49774f3a)
Olaf Hering noticed that this bug was still present, and this bugfix
was not ported to kernel.org's fork of gitweb.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On Thu, 30 Apr 2009, J.H. wrote:
> Jakub Narebski wrote:
> > I have just checked that current gitweb (1.6.2.rc1.20.g8c5b)
> > does not have this bug...
[...]
> > ... so J.H., or Lea Wiemann, or whoever manages gitweb on kernel.org
> > should backport this fix to kernel.org's fork of gitweb sources.
>
> Patches, as always, are welcome - I've got a few queued up already, but
> if I have to do it I won't be getting back around to it for a bit (there
> are other things on my priority list right now).
Here you have backport of 7e431ef (gitweb: Separate search regexp from
search text) on top of 'master' branch of kernel.org's fork of gitweb:
git://git.kernel.org/pub/scm/git/warthog9/gitweb.git
The only difference is that git_search_grep_body is in separate
gitweb/gitweb/search.pm file in kernel.org's fork. The change
is otherwise identical.
Not tested!
gitweb/gitweb.perl | 5 +++--
gitweb/gitweb/search.pm | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 984161c..aee9239 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -231,6 +231,7 @@ if (defined $page) {
}
our $searchtext = $cgi->param('s');
+our $search_regexp;
if (defined $searchtext) {
if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
die_error(undef, "Invalid search parameter");
@@ -238,7 +239,7 @@ if (defined $searchtext) {
if (length($searchtext) < 2) {
die_error(undef, "At least two characters are required for search parameter");
}
- $searchtext = quotemeta $searchtext;
+ $search_regexp = quotemeta $searchtext;
}
our $searchtype = $cgi->param('st');
@@ -1702,7 +1703,7 @@ sub git_search {
} elsif ($searchtype eq 'committer') {
$greptype = "--committer=";
}
- $greptype .= $searchtext;
+ $greptype .= $search_regexp;
my @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);
my $paging_nav = '';
diff --git a/gitweb/gitweb/search.pm b/gitweb/gitweb/search.pm
index f1aea0a..a381f4e 100644
--- a/gitweb/gitweb/search.pm
+++ b/gitweb/gitweb/search.pm
@@ -33,7 +33,7 @@ sub git_search_grep_body {
esc_html(chop_str($co{'title'}, 50)) . "<br/>");
my $comment = $co{'comment'};
foreach my $line (@$comment) {
- if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
+ if ($line =~ m/^(.*)($search_regexp)(.*)$/i) {
my $lead = esc_html($1) || "";
$lead = chop_str($lead, 30, 10);
my $match = esc_html($2) || "";
--
1.6.2
prev parent reply other threads:[~2009-04-30 10:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-29 9:12 Invalid search parameter in webinterface Olaf Hering
2009-04-29 11:44 ` [PATCH] gitweb: escape searchtext and parameters for replay Michael J Gruber
2009-04-29 12:28 ` Jakub Narebski
2009-04-29 12:52 ` Olaf Hering
2009-04-29 13:14 ` Jakub Narebski
2009-04-29 19:36 ` Jakub Narebski
2009-04-29 20:07 ` Michael J Gruber
2009-04-29 23:11 ` J.H.
2009-04-30 10:17 ` Jakub Narebski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200904301217.27154.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=warthog19@eaglescrag.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).