gitweb: Fix "next" link on bottom of page

Fix search form generation to not modify $cgi->param(...)'s.

In git_header_html() we used to use $cgi->hidden(-name => "a") etc. to
generate hidden fields; unfortunately to use this form it is required
to modify $cgi->param("a") etc., which makes href(-replay,...) use
wrong replay values.  This for example made the "next" link on the
bottom of the page has a=search instead of a=$action, and thus fails to
get you to the next page.

Because in CGI the value of a hidden field is "sticky", there is no
way to modify it short of modifying $cgi->param(...).  Therefore it
got replaced by generating <input type="hidden" ...> element [semi]
directly.

Alternate solution would be for href(-replay,...) to use values saved
in global variables, such as $action etc., instead of (re)reading them
from $cgi->param($symbol).

The bad link was reported by Kai Blin through
  http://bugs.debian.org/481902

Reported-by: Kai Blin <kai.blin@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Tested-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jakub Narebski 2008-06-02 11:54:41 +02:00 committed by Junio C Hamano
parent 3db4723ead
commit f70dda250e

View File

@ -2623,7 +2623,7 @@ EOF
print "</div>\n"; print "</div>\n";
my ($have_search) = gitweb_check_feature('search'); my ($have_search) = gitweb_check_feature('search');
if ((defined $project) && ($have_search)) { if (defined $project && $have_search) {
if (!defined $searchtext) { if (!defined $searchtext) {
$searchtext = ""; $searchtext = "";
} }
@ -2639,16 +2639,13 @@ EOF
my ($use_pathinfo) = gitweb_check_feature('pathinfo'); my ($use_pathinfo) = gitweb_check_feature('pathinfo');
if ($use_pathinfo) { if ($use_pathinfo) {
$action .= "/".esc_url($project); $action .= "/".esc_url($project);
} else {
$cgi->param("p", $project);
} }
$cgi->param("a", "search");
$cgi->param("h", $search_hash);
print $cgi->startform(-method => "get", -action => $action) . print $cgi->startform(-method => "get", -action => $action) .
"<div class=\"search\">\n" . "<div class=\"search\">\n" .
(!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") . (!$use_pathinfo &&
$cgi->hidden(-name => "a") . "\n" . $cgi->input({-name=>"p", -value=>$project, -type=>"hidden"}) . "\n") .
$cgi->hidden(-name => "h") . "\n" . $cgi->input({-name=>"a", -value=>"search", -type=>"hidden"}) . "\n" .
$cgi->input({-name=>"h", -value=>$search_hash, -type=>"hidden"}) . "\n" .
$cgi->popup_menu(-name => 'st', -default => 'commit', $cgi->popup_menu(-name => 'st', -default => 'commit',
-values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) . -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .
$cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) . $cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) .