@matheusbsbs / matheus-bagliano / commits / f70dda250e
Fork 0

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>

Jakub Narebski committed Jun 2, 2008 at 11:54 UTC f70dda250e33dd17f6fdff17d15287391d8b0952
1 file changed +5 -8
gitweb/gitweb.perl
+5 -8
@@ -2623,7 +2623,7 @@ EOF
2623 print "</div>\n";
2624
2625 my ($have_search) = gitweb_check_feature('search');
2626 - if ((defined $project) && ($have_search)) {
2626 + if (defined $project && $have_search) {
2627 if (!defined $searchtext) {
2628 $searchtext = "";
2629 }
@@ -2639,16 +2639,13 @@ EOF
2639 my ($use_pathinfo) = gitweb_check_feature('pathinfo');
2640 if ($use_pathinfo) {
2641 $action .= "/".esc_url($project);
2642 - } else {
2643 - $cgi->param("p", $project);
2642 }
2645 - $cgi->param("a", "search");
2646 - $cgi->param("h", $search_hash);
2643 print $cgi->startform(-method => "get", -action => $action) .
2644 "<div class=\"search\">\n" .
2649 - (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .
2650 - $cgi->hidden(-name => "a") . "\n" .
2651 - $cgi->hidden(-name => "h") . "\n" .
2645 + (!$use_pathinfo &&
2646 + $cgi->input({-name=>"p", -value=>$project, -type=>"hidden"}) . "\n") .
2647 + $cgi->input({-name=>"a", -value=>"search", -type=>"hidden"}) . "\n" .
2648 + $cgi->input({-name=>"h", -value=>$search_hash, -type=>"hidden"}) . "\n" .
2649 $cgi->popup_menu(-name => 'st', -default => 'commit',
2650 -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .
2651 $cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) .