[PATCH 6/7] gitweb: pass root directory as empty file parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch add the automatic propagation of the file name from f to fp
for git_treeview, if fp is undefined. To distinguish it from the root
directory, allow an empty string for this in f/fp.

Signed-off-by: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
---

It was requested, that git_treediff should propagate f to fp, if the fp
parameter is missing. So I created this patch.

As any other path could be a valid blob, I use the empty string for
the root directory.

As I personally don't like this, I have split this change into a
seperate patch:

* As git_treediff is new code, not propagating f->fp would not break any
  existing urls. 

* The f->fp propagation currently only happens in blobdiff (The only
  place, where fp is used). Is this enough to make it the standard
  gitweb parameter convention?

* The root tree is specified in git_tree with an missing f parameter.

* I don't know all security implication, if an empty file name is
  passed to all existing git function.

So I would like to drop this patch and pass the root directory as
missing f/fp parameter, which does not allow propagating f to fp.

Comments from other on this topic?

 gitweb/gitweb.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 769e755..e4d3f8f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -310,14 +310,14 @@ if (defined $project) {
 }
 
 our $file_name = $cgi->param('f');
-if (defined $file_name) {
+if (defined $file_name && $file_name ne '') {
 	if (!validate_pathname($file_name)) {
 		die_error(undef, "Invalid file parameter");
 	}
 }
 
 our $file_parent = $cgi->param('fp');
-if (defined $file_parent) {
+if (defined $file_parent && $file_parent ne '') {
 	if (!validate_pathname($file_parent)) {
 		die_error(undef, "Invalid file parent parameter");
 	}
@@ -4203,6 +4203,10 @@ sub git_treediff {
 					"raw");
 	}
 
+	$file_parent = $file_name if (!defined $file_parent);
+	$file_name = undef if(defined $file_name && $file_name eq '');
+	$file_parent = undef if(defined $file_parent && $file_parent eq '');
+
 	if (!defined $hash) {
 		if (!defined $hash_base) {
 			die_error(undef,'tree parameter missing');
-- 
1.5.1.1.85.gf1888

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]