]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: prepare git_get_projects_list for use outside 'forks'.
authorBernhard R. Link <redacted>
Mon, 30 Jan 2012 20:06:38 +0000 (21:06 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
Use of the filter option of git_get_projects_list is currently limited
to forks. It currently assumes the project belonging to the filter
directory was already validated to be visible in the project list.

To make it more generic add an optional argument to denote visibility
verification is still needed.

If there is a projects list file (GITWEB_LIST) only projects from
this list are returned anyway, so no more checks needed.

If there is no projects list file and the caller requests strict
checking (GITWEB_STRICT_EXPORT), do not jump directly to the
given directory but instead do a normal search and filter the
results instead.

The only effect of GITWEB_STRICT_EXPORT without GITWEB_LIST is to make
sure no project can be viewed without also be found starting from
project root. git_get_projects_list without this patch does not enforce
this but all callers only call it with a filter already checked this
way. With this parameter a caller can request this check if the filter
cannot be checked this way.

Signed-off-by: Bernhard R. Link <redacted>
Acked-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 28748c8e214e676bdb50110e5f8252adfa99a973831b4f860d7dd68a0e03e50b..843b0b569ba4490ba85ae421cd6071fdf0c0916abf62d4b209befc292b4029eb 100755 (executable)
@@ -2830,6 +2830,7 @@ sub git_get_project_url_list {
 
 sub git_get_projects_list {
        my $filter = shift || '';
+       my $paranoid = shift;
        my @list;
 
        if (-d $projects_list) {
@@ -2840,7 +2841,7 @@ sub git_get_projects_list {
                my $pfxlen = length("$dir");
                my $pfxdepth = ($dir =~ tr!/!!);
                # when filtering, search only given subdirectory
-               if ($filter) {
+               if ($filter && !$paranoid) {
                        $dir .= "/$filter";
                        $dir =~ s!/+$!!;
                }
@@ -2865,6 +2866,10 @@ sub git_get_projects_list {
                                }
 
                                my $path = substr($File::Find::name, $pfxlen + 1);
+                               # paranoidly only filter here
+                               if ($paranoid && $filter && $path !~ m!^\Q$filter\E/!) {
+                                       next;
+                               }
                                # we check related file in $projectroot
                                if (check_export_ok("$projectroot/$path")) {
                                        push @list, { path => $path };
This page took 0.383452 seconds and 4 git commands to generate.