threads / patch / 43523

patchRe: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list

Subject: Re: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list

## tl;dr

3 messages between Nov 3, 2006 and Nov 3, 2006. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Aneesh Kumar K.V· Nov 3, 2006, 05:11 UTC · lore

[PATCH] gitweb: Remove extra "/" in path names for git_get_project_list

Without this change we get a wrong $pfxlen value and the check_export_ok() checks with with a wrong directory name. Without this patch the below $projects_list fails with gitweb

$projects_list = "/tmp/a/b/";
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 gitweb/gitweb.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to gitweb/gitweb.perl +2 −0
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7710cc2..a0a9aaf 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -897,6 +897,8 @@ sub git_get_projects_list {
 	if (-d $projects_list) {
 		# search in directory
 		my $dir = $projects_list;
+		# remove the trailing "/"
+		$dir =~ s!/+$!!;
 		my $pfxlen = length("$dir");
 
 		File::Find::find({
-- 
1.4.3.3.gc954-dirty
Junio C Hamano· Nov 3, 2006, 05:59 UTC · re: Aneesh Kumar K.V · lore
"Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:
Show 7 quoted lines
> Without this change we get a wrong $pfxlen value and the check_export_ok()
> checks with with a wrong directory name. Without this patch the below
> $projects_list fails with gitweb
>
> $projects_list = "/tmp/a/b/";
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Hmph.  Doesn't this break $projects_list = "/", I wonder?
> +		# remove the trailing "/"
> +		$dir =~ s!/+$!!;
Jakub Narebski· Nov 3, 2006, 11:18 UTC · re: Junio C Hamano · lore
Junio C Hamano wrote:
Show 14 quoted lines
> "Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:
> 
>> Without this change we get a wrong $pfxlen value and the check_export_ok()
>> checks with with a wrong directory name. Without this patch the below
>> $projects_list fails with gitweb
>>
>> $projects_list = "/tmp/a/b/";
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
> 
> Hmph.  Doesn't this break $projects_list = "/", I wonder?
> 
>> +            # remove the trailing "/"
>> +            $dir =~ s!/+$!!;
So perhaps
        $dir =~ s!(?<=[^/])/+$!!;
(zero-width positive look-behind assertion).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

← back to recent threads