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

[PATCH 2/4] gitweb: Do not esc_html $basedir argument to git_print_tree_entry

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 21, 2006, 15:53 UTC
Message-ID
<200610211753.09343.jnareb@gmail.com>
In-Reply-To
<200610211750.49188.jnareb@gmail.com>

In git_tree, rename $base variable (which is passed as $basedir argument to git_print_tree_entry) to $basedir. Do not esc_html $basedir, as it is part of file_name ('f') argument in link and not printed. Add '/' at the end only if $basedir is not empty (it is empty for top directory) and doesn't end in '/' already.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
BUGFIX patch.
 gitweb/gitweb.perl |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c457884..209b318 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2834,7 +2834,7 @@ sub git_tree {
 	my $refs = git_get_references();
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
-	my $base = "";
+	my $basedir = '';
 	my ($have_blame) = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
@@ -2862,7 +2862,10 @@ sub git_tree {
 		print "<div class=\"title\">$hash</div>\n";
 	}
 	if (defined $file_name) {
-		$base = esc_html("$file_name/");
+		$basedir = $file_name;
+		if ($basedir ne '' && substr($basedir, -1) ne '/') {
+			$basedir .= '/';
+		}
 	}
 	git_print_page_path($file_name, 'tree', $hash_base);
 	print "<div class=\"page_body\">\n";
@@ -2878,7 +2881,7 @@ sub git_tree {
 		}
 		$alternate ^= 1;
 
-		git_print_tree_entry(\%t, $base, $hash_base, $have_blame);
+		git_print_tree_entry(\%t, $basedir, $hash_base, $have_blame);
 
 		print "</tr>\n";
 	}
-- 
1.4.2.1
Previous: Luben TuikovNext: Jakub Narebski
Message 9 of 11 in “gitweb: Improving tree view (plus some cleanups)”
  1. 0/4 gitweb: Improving tree view (plus some cleanups)Jakub Narebski, Oct 21, 2006
  2. 1/4 gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)Jakub Narebski, Oct 21, 2006
  3. Junio C HamanoOct 22, 2006
  4. Jakub NarebskiOct 22, 2006
  5. Linus TorvaldsOct 22, 2006
  6. Jakub NarebskiOct 22, 2006
  7. Junio C HamanoOct 22, 2006
  8. Luben TuikovOct 22, 2006
  9. 2/4 gitweb: Do not esc_html $basedir argument to git_print_tree_entryJakub Narebski, Oct 21, 2006
  10. 3/4 gitweb: Improve git_print_page_pathJakub Narebski, Oct 21, 2006
  11. 4/4 gitweb: Add '..' (up directory) to tree view if applicableJakub Narebski, Oct 21, 2006

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.