Skip to content

Commit dc6d9b4

Browse files
dstosbergJunio C Hamano
authored andcommitted
gitweb: Declare global variables with "our"
Variables declared with "my" in the file scope cannot be accessed from subroutines with mod_perl. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent e0becd9 commit dc6d9b4

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

gitweb/gitweb.cgi

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,53 @@ use Encode;
1616
use Fcntl ':mode';
1717
binmode STDOUT, ':utf8';
1818

19-
my $cgi = new CGI;
20-
my $version = "267";
21-
my $my_url = $cgi->url();
22-
my $my_uri = $cgi->url(-absolute => 1);
23-
my $rss_link = "";
19+
our $cgi = new CGI;
20+
our $version = "267";
21+
our $my_url = $cgi->url();
22+
our $my_uri = $cgi->url(-absolute => 1);
23+
our $rss_link = "";
2424

2525
# location of the git-core binaries
26-
my $gitbin = "/usr/bin";
26+
our $gitbin = "/usr/bin";
2727

2828
# absolute fs-path which will be prepended to the project path
29-
#my $projectroot = "/pub/scm";
30-
my $projectroot = "/home/kay/public_html/pub/scm";
29+
#our $projectroot = "/pub/scm";
30+
our $projectroot = "/home/kay/public_html/pub/scm";
3131

3232
# version of the git-core binaries
33-
my $git_version = qx($gitbin/git --version);
33+
our $git_version = qx($gitbin/git --version);
3434
if ($git_version =~ m/git version (.*)$/) {
3535
$git_version = $1;
3636
} else {
3737
$git_version = "unknown";
3838
}
3939

4040
# location for temporary files needed for diffs
41-
my $git_temp = "/tmp/gitweb";
41+
our $git_temp = "/tmp/gitweb";
4242

4343
# target of the home link on top of all pages
44-
my $home_link = $my_uri;
44+
our $home_link = $my_uri;
4545

4646
# html text to include at home page
47-
my $home_text = "indextext.html";
47+
our $home_text = "indextext.html";
4848

4949
# URI of default stylesheet
50-
my $stylesheet = "gitweb.css";
50+
our $stylesheet = "gitweb.css";
5151

5252
# source of projects list
53-
#my $projects_list = $projectroot;
54-
my $projects_list = "index/index.aux";
53+
#our $projects_list = $projectroot;
54+
our $projects_list = "index/index.aux";
5555

5656
# default blob_plain mimetype and default charset for text/plain blob
57-
my $default_blob_plain_mimetype = 'text/plain';
58-
my $default_text_plain_charset = undef;
57+
our $default_blob_plain_mimetype = 'text/plain';
58+
our $default_text_plain_charset = undef;
5959

6060
# file to use for guessing MIME types before trying /etc/mime.types
6161
# (relative to the current git repository)
62-
my $mimetypes_file = undef;
63-
62+
our $mimetypes_file = undef;
6463

6564
# input validation and dispatch
66-
my $action = $cgi->param('a');
65+
our $action = $cgi->param('a');
6766
if (defined $action) {
6867
if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
6968
undef $action;
@@ -78,15 +77,15 @@ if (defined $action) {
7877
}
7978
}
8079

81-
my $order = $cgi->param('o');
80+
our $order = $cgi->param('o');
8281
if (defined $order) {
8382
if ($order =~ m/[^0-9a-zA-Z_]/) {
8483
undef $order;
8584
die_error(undef, "Invalid order parameter.");
8685
}
8786
}
8887

89-
my $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
88+
our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
9089
if (defined $project) {
9190
$project =~ s|^/||; $project =~ s|/$||;
9291
$project = validate_input($project);
@@ -109,47 +108,47 @@ if (defined $project) {
109108
exit;
110109
}
111110

112-
my $file_name = $cgi->param('f');
111+
our $file_name = $cgi->param('f');
113112
if (defined $file_name) {
114113
$file_name = validate_input($file_name);
115114
if (!defined($file_name)) {
116115
die_error(undef, "Invalid file parameter.");
117116
}
118117
}
119118

120-
my $hash = $cgi->param('h');
119+
our $hash = $cgi->param('h');
121120
if (defined $hash) {
122121
$hash = validate_input($hash);
123122
if (!defined($hash)) {
124123
die_error(undef, "Invalid hash parameter.");
125124
}
126125
}
127126

128-
my $hash_parent = $cgi->param('hp');
127+
our $hash_parent = $cgi->param('hp');
129128
if (defined $hash_parent) {
130129
$hash_parent = validate_input($hash_parent);
131130
if (!defined($hash_parent)) {
132131
die_error(undef, "Invalid hash parent parameter.");
133132
}
134133
}
135134

136-
my $hash_base = $cgi->param('hb');
135+
our $hash_base = $cgi->param('hb');
137136
if (defined $hash_base) {
138137
$hash_base = validate_input($hash_base);
139138
if (!defined($hash_base)) {
140139
die_error(undef, "Invalid hash base parameter.");
141140
}
142141
}
143142

144-
my $page = $cgi->param('pg');
143+
our $page = $cgi->param('pg');
145144
if (defined $page) {
146145
if ($page =~ m/[^0-9]$/) {
147146
undef $page;
148147
die_error(undef, "Invalid page parameter.");
149148
}
150149
}
151150

152-
my $searchtext = $cgi->param('s');
151+
our $searchtext = $cgi->param('s');
153152
if (defined $searchtext) {
154153
if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
155154
undef $searchtext;

0 commit comments

Comments
 (0)