threads / patch / 16882

patchgitweb: Fix export check in git_get_projects_list

Subject: [PATCH] gitweb: Fix export check in git_get_projects_list

## tl;dr

4 messages between Dec 27, 2008 and Dec 29, 2008. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Devin Doucette· Dec 27, 2008, 09:39 UTC · lore

When $filter was empty, the path passed to check_export_ok would contain an extra '/', which some implementations of export_auth_hook are sensitive to.

It makes more sense to fix this here than to handle the special case in each implementation of export_auth_hook.

Signed-off-by: Devin Doucette <devin@doucette.cc>
---
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Show changes to gitweb/gitweb.perl +3 −2
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8f574c7..99f71b4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2147,8 +2147,9 @@ sub git_get_projects_list {

 				my $subdir = substr($File::Find::name, $pfxlen + 1);
 				# we check related file in $projectroot
-				if (check_export_ok("$projectroot/$filter/$subdir")) {
-					push @list, { path => ($filter ? "$filter/" : '') . $subdir };
+				my $path = ($filter ? "$filter/" : '') . $subdir;
+				if (check_export_ok("$projectroot/$path")) {
+					push @list, { path => $path };
 					$File::Find::prune = 1;
 				}
 			},
-- 
1.6.1.rc4
Jakub Narebski· Dec 28, 2008, 02:12 UTC · re: Devin Doucette · lore

Re: [PATCH] gitweb: Fix export check in git_get_projects_list

On Sat, 27 Dec 2008, Devin Doucette wrote:
Show 8 quoted lines
> When $filter was empty, the path passed to check_export_ok would
> contain an extra '/', which some implementations of export_auth_hook
> are sensitive to.
> 
> It makes more sense to fix this here than to handle the special case
> in each implementation of export_auth_hook.
> 
> Signed-off-by: Devin Doucette <devin@doucette.cc>
Good catch. Thanks.
Acked-by: Jakub Narebski <jnareb@gmail.com>
Show 15 quoted lines
> ---
>  gitweb/gitweb.perl |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 8f574c7..99f71b4 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -2147,8 +2147,9 @@ sub git_get_projects_list {
> 
>  				my $subdir = substr($File::Find::name, $pfxlen + 1);
>  				# we check related file in $projectroot
> -				if (check_export_ok("$projectroot/$filter/$subdir")) {
> -					push @list, { path => ($filter ? "$filter/" : '') . $subdir };
> +				my $path = ($filter ? "$filter/" : '') . $subdir;
Nice and clear, but wouldn't be better to use slightly more effective
+				my $path = $filter ? "$filter/$subdir" : $subdir;
Or even, taking care of the case when $filter eq '0'
+				my $path = defined $filter && $filter ne '' ? "$filter/$subdir" : $subdir;
Show 8 quoted lines
> +				if (check_export_ok("$projectroot/$path")) {
> +					push @list, { path => $path };
>  					$File::Find::prune = 1;
>  				}
>  			},
> -- 
> 1.6.1.rc4
> 
-- 
Jakub Narebski
Poland
Junio C Hamano· Dec 28, 2008, 06:54 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: Fix export check in git_get_projects_list

Jakub Narebski <jnareb@gmail.com> writes:
Show 12 quoted lines
> On Sat, 27 Dec 2008, Devin Doucette wrote:
>
>> When $filter was empty, the path passed to check_export_ok would
>> contain an extra '/', which some implementations of export_auth_hook
>> are sensitive to.
>> 
>> It makes more sense to fix this here than to handle the special case
>> in each implementation of export_auth_hook.
>> 
>> Signed-off-by: Devin Doucette <devin@doucette.cc>
>
> Good catch. Thanks.
Thanks, both.  Will queue for 'maint'.
Jakub Narebski· Dec 29, 2008, 12:29 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: Fix export check in git_get_projects_list

On Sun, 28 Dec 2008, Jakub Narebski wrote:
> On Sat, 27 Dec 2008, Devin Doucette wrote:
Show 19 quoted lines
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 8f574c7..99f71b4 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -2147,8 +2147,9 @@ sub git_get_projects_list {
> > 
> >  				my $subdir = substr($File::Find::name, $pfxlen + 1);
> >  				# we check related file in $projectroot
> > -				if (check_export_ok("$projectroot/$filter/$subdir")) {
> > -					push @list, { path => ($filter ? "$filter/" : '') . $subdir };
> > +				my $path = ($filter ? "$filter/" : '') . $subdir;
> 
> Nice and clear, but wouldn't be better to use slightly more effective
> 
> +				my $path = $filter ? "$filter/$subdir" : $subdir;
> 
> Or even, taking care of the case when $filter eq '0'
> 
> +				my $path = defined $filter && $filter ne '' ? "$filter/$subdir" : $subdir;
Err, actually with "$filter ||= '';" earlier in git_get_projects_list
this is not necessary, and is not an improvement.
 
-- 
Jakub Narebski
Poland

← back to recent threads