{"thread":{"id":"39035","subject":"[PATCH] gitweb: avoid double / in search form action link","startedAt":"2015-04-08T13:49:04Z","lastAt":"2015-04-08T13:49:04Z","messageCount":1,"participants":["Tony Finch"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"259173","messageId":"alpine.LSU.2.00.1504081448410.10193@hermes-1.csi.cam.ac.uk","threadId":"39035","inReplyTo":null,"subject":"[PATCH] gitweb: avoid double / in search form action link","fromName":"Tony Finch","fromEmail":"dot@dotat.at","sentAt":"2015-04-08T13:49:04Z","receivedAt":"2015-04-08T13:49:04Z","isPatch":true,"sender":{"key":"dot@dotat.at","avatar":"https://avatars.githubusercontent.com/u/68429?v=4"},"body":"The in-project search form needs to duplicate some of the logic of\nthe href() subroutine, because the parameters need to be encoded\nin the form rather than in the URL.  However it failed to correctly\nappend the project PATH_INFO in cases when there is a trailing slash\non gitweb's self-referential URL, and failed to correctly follow\nPATH_INFO escaping rules.\n\nThis change makes the form action URL consistent with the URL\ngenerated by href().\n\nSigned-off-by: Tony Finch <dot@dotat.at>\n---\n gitweb/gitweb.perl | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a02f3e4..05acd73 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4129,10 +4129,14 @@ sub print_search_form {\n \t} else {\n \t\t$search_hash = \"HEAD\";\n \t}\n+\t# We can't use href() here because we need to encode the\n+\t# URL parameters into the form, not into the action link.\n \tmy $action = $my_uri;\n \tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n \tif ($use_pathinfo) {\n-\t\t$action .= \"/\".esc_url($project);\n+\t\t# See notes about doubled / in href()\n+\t\t$action =~ s,/$,,;\n+\t\t$action .= \"/\".esc_path_info($project);\n \t}\n \tprint $cgi->start_form(-method => \"get\", -action => $action) .\n \t      \"<div class=\\\"search\\\">\\n\" .\n-- \n2.2.1.68.g56d9796\n"}]}