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

[PATCH 1/2] gitweb: Fix bug in evaluate_path_info

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 13, 2010, 11:33 UTC
Message-ID
<20101013112738.9292.46672.stgit@localhost.localdomain>

There was bug in parsing "project/:/file" and "project/:/" path_info URLs, with implicit HEAD as 'hash_base'.

For such URLs the refname is empty, and before this fix regexp for parsing path_info fragment assumed that it is always non-empty.

Refname cannot contain ':', as per 'git check-ref-format'.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This was detected by t9500-gitweb-standalone-no-errors test script,
but only after applying second patch in this series.

Unfortunately it is not easy to detect that gitweb generated correct view; t9500 script only checks if Perl doesn't show any errors or warnings. That is why I have not added test for this issue (yet).

 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 15b5bb9..9116a0e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -780,10 +780,10 @@ sub evaluate_path_info {
 		'history',
 	);
 
-	# we want to catch
+	# we want to catch, among others
 	# [$hash_parent_base[:$file_parent]..]$hash_parent[:$file_name]
 	my ($parentrefname, $parentpathname, $refname, $pathname) =
-		($path_info =~ /^(?:(.+?)(?::(.+))?\.\.)?(.+?)(?::(.+))?$/);
+		($path_info =~ /^(?:(.+?)(?::(.+))?\.\.)?([^:]+?)?(?::(.+))?$/);
 
 	# first, analyze the 'current' part
 	if (defined $pathname) {
Next: Jakub Narebski
Message 1 of 2 in “gitweb: Fix bug in evaluate_path_info”
  1. 1/2 gitweb: Fix bug in evaluate_path_infoJakub Narebski, Oct 13, 2010
  2. 2/2 gitweb: Improve behavior for actionless path_info gitweb URLsJakub Narebski, Oct 13, 2010

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.