Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
8dae2315
Commit
8dae2315
authored
Feb 26, 2017
by
Dylan William Hardison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1291006 - Under PSGI/Plack, non-existing files lead to index.cgi
parent
c6363140
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
+30
-15
app.psgi
app.psgi
+30
-15
No files found.
app.psgi
View file @
8dae2315
...
@@ -46,6 +46,8 @@ use constant STATIC => qw(
...
@@ -46,6 +46,8 @@ use constant STATIC => qw(
skins
skins
)
;
)
;
$ENV
{
BZ_PLACK
}
=
'Plack/'
.
Plack
->
VERSION
;
my
$app
=
builder
{
my
$app
=
builder
{
my
$static_paths
my
$static_paths
=
join
(
'|'
,
sort
{
length
$b
<=>
length
$a
||
$a
cmp
$b
}
STATIC
);
=
join
(
'|'
,
sort
{
length
$b
<=>
length
$a
||
$a
cmp
$b
}
STATIC
);
...
@@ -53,41 +55,54 @@ my $app = builder {
...
@@ -53,41 +55,54 @@ my $app = builder {
path
=>
qr{^/($static_paths)/}
,
path
=>
qr{^/($static_paths)/}
,
root
=>
Bugzilla::Constants::
bz_locations
->
{
cgi_path
};
root
=>
Bugzilla::Constants::
bz_locations
->
{
cgi_path
};
$ENV
{
BZ_PLACK
}
=
'Plack/'
.
Plack
->
VERSION
;
my
$map
=
Plack::App::
URLMap
->
new
;
my
@cgis
=
glob
(
'*.cgi'
);
my
$shutdown_app
my
$shutdown_app
=
Plack::App::
WrapCGI
->
new
(
script
=>
'shutdown.cgi'
)
->
to_app
;
=
Plack::App::
WrapCGI
->
new
(
script
=>
'shutdown.cgi'
)
->
to_app
;
my
@scripts
=
glob
(
'*.cgi'
);
foreach
my
$cgi_script
(
@cgis
)
{
my
%
cgi_app
;
foreach
my
$script
(
@scripts
)
{
my
$base_name
=
basename
(
$script
);
next
if
$base_name
eq
'shutdown.cgi'
;
my
$app
my
$app
=
eval
{
Plack::App::
WrapCGI
->
new
(
script
=>
$
cgi_
script
)
->
to_app
};
=
eval
{
Plack::App::
WrapCGI
->
new
(
script
=>
$script
)
->
to_app
};
# Some CGI scripts won't compile if not all optional Perl modules are
# Some CGI scripts won't compile if not all optional Perl modules are
# installed. That's expected.
# installed. That's expected.
if
(
$@
)
{
unless
(
$app
)
{
warn
"Cannot compile $
cgi_script.
Skipping!\n"
;
warn
"Cannot compile $
script: $@\n
Skipping!\n"
;
next
;
next
;
}
}
my
$wrapper
=
sub
{
my
$wrapper
=
sub
{
my
$ret
=
Bugzilla::
init_page
();
my
$ret
=
Bugzilla::
init_page
();
my
$res
my
$res
=
(
$ret
eq
'-1'
&&
$
cgi_
script
ne
'editparams.cgi'
)
=
(
$ret
eq
'-1'
&&
$script
ne
'editparams.cgi'
)
?
$shutdown_app
->
(
@_
)
?
$shutdown_app
->
(
@_
)
:
$app
->
(
@_
);
:
$app
->
(
@_
);
Bugzilla::
_cleanup
();
Bugzilla::
_cleanup
();
return
$res
;
return
$res
;
};
};
$cgi_app
{
$base_name
}
=
$wrapper
;
}
my
$base_name
=
basename
(
$cgi_script
);
foreach
my
$cgi_name
(
keys
%
cgi_app
)
{
$map
->
map
(
'/'
=>
$wrapper
)
if
$cgi_script
eq
'index.cgi'
;
mount
"/$cgi_name"
=>
$cgi_app
{
$cgi_name
};
$map
->
map
(
'/rest'
=>
$wrapper
)
if
$cgi_script
eq
'rest.cgi'
;
$map
->
map
(
"/$base_name"
=>
$wrapper
);
}
}
$map
->
to_app
;
# so mount / => $app will make *all* files redirect to the index.
# instead we use an inline middleware to rewrite / to /index.cgi
enable
sub
{
my
$app
=
shift
;
return
sub
{
my
$env
=
shift
;
$env
->
{
PATH_INFO
}
=
'/index.cgi'
if
$env
->
{
PATH_INFO
}
eq
'/'
;
return
$app
->
(
$env
);
};
};
mount
"/rest"
=>
$cgi_app
{
"rest.cgi"
};
};
};
unless
(
caller
)
{
unless
(
caller
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment