@@ -760,6 +760,7 @@ sub check_loadavg {
760
760
search_use_regexp => " sr" ,
761
761
ctag => " by_tag" ,
762
762
diff_style => " ds" ,
763
+ project_filter => " pf" ,
763
764
# this must be last entry (for manipulation from JavaScript)
764
765
javascript => " js"
765
766
);
@@ -976,7 +977,7 @@ sub evaluate_path_info {
976
977
977
978
our ($action , $project , $file_name , $file_parent , $hash , $hash_parent , $hash_base ,
978
979
$hash_parent_base , @extra_options , $page , $searchtype , $search_use_regexp ,
979
- $searchtext , $search_regexp );
980
+ $searchtext , $search_regexp , $project_filter );
980
981
sub evaluate_and_validate_params {
981
982
our $action = $input_params {' action' };
982
983
if (defined $action ) {
@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {
994
995
}
995
996
}
996
997
998
+ our $project_filter = $input_params {' project_filter' };
999
+ if (defined $project_filter ) {
1000
+ if (!validate_pathname($project_filter )) {
1001
+ die_error(404, " Invalid project_filter parameter" );
1002
+ }
1003
+ }
1004
+
997
1005
our $file_name = $input_params {' file_name' };
998
1006
if (defined $file_name ) {
999
1007
if (!validate_pathname($file_name )) {
@@ -2829,10 +2837,9 @@ sub git_get_project_url_list {
2829
2837
2830
2838
sub git_get_projects_list {
2831
2839
my $filter = shift || ' ' ;
2840
+ my $paranoid = shift ;
2832
2841
my @list ;
2833
2842
2834
- $filter =~ s /\. git$// ;
2835
-
2836
2843
if (-d $projects_list ) {
2837
2844
# search in directory
2838
2845
my $dir = $projects_list ;
@@ -2841,7 +2848,7 @@ sub git_get_projects_list {
2841
2848
my $pfxlen = length (" $dir " );
2842
2849
my $pfxdepth = ($dir =~ tr ! /!! );
2843
2850
# when filtering, search only given subdirectory
2844
- if ($filter ) {
2851
+ if ($filter && ! $paranoid ) {
2845
2852
$dir .= " /$filter " ;
2846
2853
$dir =~ s ! /+$!! ;
2847
2854
}
@@ -2866,6 +2873,10 @@ sub git_get_projects_list {
2866
2873
}
2867
2874
2868
2875
my $path = substr ($File::Find::name , $pfxlen + 1);
2876
+ # paranoidly only filter here
2877
+ if ($paranoid && $filter && $path !~ m ! ^\Q $filter \E /! ) {
2878
+ next ;
2879
+ }
2869
2880
# we check related file in $projectroot
2870
2881
if (check_export_ok(" $projectroot /$path " )) {
2871
2882
push @list , { path => $path };
@@ -3731,7 +3742,12 @@ sub run_highlighter {
3731
3742
sub get_page_title {
3732
3743
my $title = to_utf8($site_name );
3733
3744
3734
- return $title unless (defined $project );
3745
+ unless (defined $project ) {
3746
+ if (defined $project_filter ) {
3747
+ $title .= " - " . to_utf8($project_filter );
3748
+ }
3749
+ return $title ;
3750
+ }
3735
3751
$title .= " - " . to_utf8($project );
3736
3752
3737
3753
return $title unless (defined $action );
@@ -3825,12 +3841,27 @@ sub print_header_links {
3825
3841
}
3826
3842
}
3827
3843
3844
+ sub print_nav_breadcrumbs_path {
3845
+ my $dirprefix = undef ;
3846
+ while (my $part = shift ) {
3847
+ $dirprefix .= " /" if defined $dirprefix ;
3848
+ $dirprefix .= $part ;
3849
+ print $cgi -> a({-href => href(project => undef ,
3850
+ project_filter => $dirprefix ,
3851
+ action => " project_list" )},
3852
+ esc_html($part )) . " / " ;
3853
+ }
3854
+ }
3855
+
3828
3856
sub print_nav_breadcrumbs {
3829
3857
my %opts = @_ ;
3830
3858
3831
3859
print $cgi -> a({-href => esc_url($home_link )}, $home_link_str ) . " / " ;
3832
3860
if (defined $project ) {
3833
- print $cgi -> a({-href => href(action => " summary" )}, esc_html($project ));
3861
+ my @dirname = split ' /' , $project ;
3862
+ my $projectbasename = pop @dirname ;
3863
+ print_nav_breadcrumbs_path(@dirname );
3864
+ print $cgi -> a({-href => href(action => " summary" )}, esc_html($projectbasename ));
3834
3865
if (defined $action ) {
3835
3866
my $action_print = $action ;
3836
3867
if (defined $opts {-action_extra}) {
@@ -3843,6 +3874,8 @@ sub print_nav_breadcrumbs {
3843
3874
print " / $opts {-action_extra}" ;
3844
3875
}
3845
3876
print " \n " ;
3877
+ } elsif (defined $project_filter ) {
3878
+ print_nav_breadcrumbs_path(split ' /' , $project_filter );
3846
3879
}
3847
3880
}
3848
3881
@@ -3965,9 +3998,11 @@ sub git_footer_html {
3965
3998
}
3966
3999
3967
4000
} else {
3968
- print $cgi -> a({-href => href(project => undef , action => " opml" ),
4001
+ print $cgi -> a({-href => href(project => undef , action => " opml" ,
4002
+ project_filter => $project_filter ),
3969
4003
-class => $feed_class }, " OPML" ) . " " ;
3970
- print $cgi -> a({-href => href(project => undef , action => " project_index" ),
4004
+ print $cgi -> a({-href => href(project => undef , action => " project_index" ,
4005
+ project_filter => $project_filter ),
3971
4006
-class => $feed_class }, " TXT" ) . " \n " ;
3972
4007
}
3973
4008
print " </div>\n " ; # class="page_footer"
@@ -5125,6 +5160,34 @@ sub git_patchset_body {
5125
5160
5126
5161
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5127
5162
5163
+ sub git_project_search_form {
5164
+ my ($searchtext , $search_use_regexp );
5165
+
5166
+ my $limit = ' ' ;
5167
+ if ($project_filter ) {
5168
+ $limit = " in '$project_filter /'" ;
5169
+ }
5170
+
5171
+ print " <div class=\" projsearch\" >\n " ;
5172
+ print $cgi -> startform(-method => ' get' , -action => $my_uri ) .
5173
+ $cgi -> hidden(-name => ' a' , -value => ' project_list' ) . " \n " ;
5174
+ print $cgi -> hidden(-name => ' pf' , -value => $project_filter ). " \n "
5175
+ if (defined $project_filter );
5176
+ print $cgi -> textfield(-name => ' s' , -value => $searchtext ,
5177
+ -title => " Search project by name and description$limit " ,
5178
+ -size => 60) . " \n " .
5179
+ " <span title=\" Extended regular expression\" >" .
5180
+ $cgi -> checkbox(-name => ' sr' , -value => 1, -label => ' re' ,
5181
+ -checked => $search_use_regexp ) .
5182
+ " </span>\n " .
5183
+ $cgi -> submit(-name => ' btnS' , -value => ' Search' ) .
5184
+ $cgi -> end_form() . " \n " .
5185
+ $cgi -> a({-href => href(project => undef , searchtext => undef ,
5186
+ project_filter => $project_filter )},
5187
+ esc_html(" List all projects$limit " )) . " <br />\n " ;
5188
+ print " </div>\n " ;
5189
+ }
5190
+
5128
5191
# fills project list info (age, description, owner, category, forks)
5129
5192
# for each project in the list, removing invalid projects from
5130
5193
# returned list
@@ -5981,7 +6044,7 @@ sub git_project_list {
5981
6044
die_error(400, " Unknown order parameter" );
5982
6045
}
5983
6046
5984
- my @list = git_get_projects_list();
6047
+ my @list = git_get_projects_list($project_filter , $strict_export );
5985
6048
if (!@list ) {
5986
6049
die_error(404, " No projects found" );
5987
6050
}
@@ -5992,11 +6055,8 @@ sub git_project_list {
5992
6055
insert_file($home_text );
5993
6056
print " </div>\n " ;
5994
6057
}
5995
- print $cgi -> startform(-method => " get" ) .
5996
- " <p class=\" projsearch\" >Search:\n " .
5997
- $cgi -> textfield(-name => " s" , -value => $searchtext ) . " \n " .
5998
- " </p>" .
5999
- $cgi -> end_form() . " \n " ;
6058
+
6059
+ git_project_search_form($searchtext , $search_use_regexp );
6000
6060
git_project_list_body(\@list , $order );
6001
6061
git_footer_html();
6002
6062
}
@@ -6007,7 +6067,9 @@ sub git_forks {
6007
6067
die_error(400, " Unknown order parameter" );
6008
6068
}
6009
6069
6010
- my @list = git_get_projects_list($project );
6070
+ my $filter = $project ;
6071
+ $filter =~ s /\. git$// ;
6072
+ my @list = git_get_projects_list($filter );
6011
6073
if (!@list ) {
6012
6074
die_error(404, " No forks found" );
6013
6075
}
@@ -6020,7 +6082,7 @@ sub git_forks {
6020
6082
}
6021
6083
6022
6084
sub git_project_index {
6023
- my @projects = git_get_projects_list();
6085
+ my @projects = git_get_projects_list($project_filter , $strict_export );
6024
6086
if (!@projects ) {
6025
6087
die_error(404, " No projects found" );
6026
6088
}
@@ -6066,7 +6128,9 @@ sub git_summary {
6066
6128
6067
6129
if ($check_forks ) {
6068
6130
# find forks of a project
6069
- @forklist = git_get_projects_list($project );
6131
+ my $filter = $project ;
6132
+ $filter =~ s /\. git$// ;
6133
+ @forklist = git_get_projects_list($filter );
6070
6134
# filter out forks of forks
6071
6135
@forklist = filter_forks_from_projects_list(\@forklist )
6072
6136
if (@forklist );
@@ -7857,7 +7921,7 @@ sub git_atom {
7857
7921
}
7858
7922
7859
7923
sub git_opml {
7860
- my @list = git_get_projects_list();
7924
+ my @list = git_get_projects_list($project_filter , $strict_export );
7861
7925
if (!@list ) {
7862
7926
die_error(404, " No projects found" );
7863
7927
}
@@ -7868,11 +7932,17 @@ sub git_opml {
7868
7932
-content_disposition => ' inline; filename="opml.xml"' );
7869
7933
7870
7934
my $title = esc_html($site_name );
7935
+ my $filter = " within subdirectory " ;
7936
+ if (defined $project_filter ) {
7937
+ $filter .= esc_html($project_filter );
7938
+ } else {
7939
+ $filter = " " ;
7940
+ }
7871
7941
print <<XML ;
7872
7942
<?xml version =" 1.0" encoding =" utf-8" ?>
7873
7943
<opml version =" 1.0" >
7874
7944
<head >
7875
- <title >$title OPML Export</title >
7945
+ <title >$title OPML Export$filter </title >
7876
7946
</head >
7877
7947
<body >
7878
7948
<outline text =" git RSS feeds" >
0 commit comments