git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: accept trailing "/" in $project_list

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jan 4, 2012, 10:07 UTC
Message-ID
<1325671665-16847-1-git-send-email-Matthieu.Moy@imag.fr>

The current code is removing the trailing "/", but computing the string length on the previous value, i.e. with the trailing "/". Later in the code, we do

  my $path = substr($File::Find::name, $pfxlen + 1);

And the "$pfxlen + 1" is supposed to mean "the length of the prefix, plus 1 for the / separating the prefix and the path", but with an incorrect $pfxlen, this basically eats the first character of the path, and yields "404 - No projects found".

While we're there, also fix $pfxdepth to use $dir, although a change of 1 in the depth shouldn't really matter.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
I'm not fluent in Perl, and not familiar at all with gitweb, but this
sounds a rather obvious (too obvious?) fix.
 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f80f259..4512b89 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2835,8 +2835,8 @@ sub git_get_projects_list {
 		my $dir = $projects_list;
 		# remove the trailing "/"
 		$dir =~ s!/+$!!;
-		my $pfxlen = length("$projects_list");
-		my $pfxdepth = ($projects_list =~ tr!/!!);
+		my $pfxlen = length("$dir");
+		my $pfxdepth = ($dir =~ tr!/!!);
 		# when filtering, search only given subdirectory
 		if ($filter) {
 			$dir .= "/$filter";
-- 
1.7.8.384.g29bb3
Next: Junio C Hamano
Message 1 of 2 in “gitweb: accept trailing "/" in $project_list”
  1. gitweb: accept trailing "/" in $project_listMatthieu Moy, Jan 4, 2012
  2. Junio C HamanoJan 4, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.