Skip to content

Commit 348a658

Browse files
Bernhard R. Linkgitster
authored andcommitted
gitweb: prepare git_get_projects_list for use outside 'forks'.
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 <[email protected]> Acked-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c7cd17 commit 348a658

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gitweb/gitweb.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,7 @@ sub git_get_project_url_list {
28272827

28282828
sub git_get_projects_list {
28292829
my $filter = shift || '';
2830+
my $paranoid = shift;
28302831
my @list;
28312832

28322833
if (-d $projects_list) {
@@ -2837,7 +2838,7 @@ sub git_get_projects_list {
28372838
my $pfxlen = length("$dir");
28382839
my $pfxdepth = ($dir =~ tr!/!!);
28392840
# when filtering, search only given subdirectory
2840-
if ($filter) {
2841+
if ($filter && !$paranoid) {
28412842
$dir .= "/$filter";
28422843
$dir =~ s!/+$!!;
28432844
}
@@ -2862,6 +2863,10 @@ sub git_get_projects_list {
28622863
}
28632864

28642865
my $path = substr($File::Find::name, $pfxlen + 1);
2866+
# paranoidly only filter here
2867+
if ($paranoid && $filter && $path !~ m!^\Q$filter\E/!) {
2868+
next;
2869+
}
28652870
# we check related file in $projectroot
28662871
if (check_export_ok("$projectroot/$path")) {
28672872
push @list, { path => $path };

0 commit comments

Comments
 (0)