From: Junio C Hamano <gitster@pobox.com>
To: Charles McGarvey <chazmcgarvey@brokenzipper.com>
Cc: git@vger.kernel.org, Jakub Narebski <jnareb@gmail.com>
Subject: Re: [PATCH] gitweb: fix problem causing erroneous project list
Date: Wed, 05 Jun 2013 12:17:12 -0700 [thread overview]
Message-ID: <7vd2s01i6f.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130605043524.GA2453@compy.Home> (Charles McGarvey's message of "Tue, 4 Jun 2013 22:44:28 -0600")
Charles McGarvey <chazmcgarvey@brokenzipper.com> writes:
> The bug is manifest when running gitweb in a persistent process (e.g.
> FastCGI, PSGI), and it's easy to reproduce. If a gitweb request
> includes the searchtext parameter (i.e. s), subsequent requests using
> the project_list action--which is the default action--and without
> a searchtext parameter will be filtered by the searchtext value of the
> first request. This is because the value of the $search_regexp global
> (the value of which is based on the searchtext parameter) is currently
> being persisted between requests.
>
> Instead, clear $search_regexp before dispatching each request.
>
> Signed-off-by: Charles McGarvey <chazmcgarvey@brokenzipper.com>
> ---
> I don't think there are currently any persistent-process gitweb tests to
> copy from, so writing a test for this seems to be non-trivial.
The problem description makes sense to me, and clearing with "undef"
is in line with the case where the CGI is run for the first time, so
I think this patch is correct.
Will wait for a while to give Jakub some time to comment on (like:
Ack ;-) and then apply. Thanks.
By the way, I looked at how $search_regexp is used in the code:
* esc_html_match_hl and esc_html_match_hl__chopped (called from
git_project_list_rows, for example) want to have "undef"; an
empty string will not do.
* search_projects_list (called from git_project_list_body)
x git_search_files and git_search_grep_body assume that
$search_regexp can be interpolated in m//, which is not very
nice. They want an empty string.
So as an independent fix, the two subs may want to be fixed if we
want to be undef clean. Or am I missing something? Jakub, isn't
this kind of "undef" reference t9500 was designed to catch?
> gitweb/gitweb.perl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 80950c0..8d69ada 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1086,7 +1086,7 @@ sub evaluate_and_validate_params {
> our $search_use_regexp = $input_params{'search_use_regexp'};
>
> our $searchtext = $input_params{'searchtext'};
> - our $search_regexp;
> + our $search_regexp = undef;
> if (defined $searchtext) {
> if (length($searchtext) < 2) {
> die_error(403, "At least two characters are required for search parameter");
next prev parent reply other threads:[~2013-06-05 19:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 4:44 [PATCH] gitweb: fix problem causing erroneous project list Charles McGarvey
2013-06-05 19:17 ` Junio C Hamano [this message]
2013-06-07 20:39 ` Jakub Narębski
2013-06-07 21:59 ` Junio C Hamano
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=7vd2s01i6f.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=chazmcgarvey@brokenzipper.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/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).