Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
5f1f8e4e
Commit
5f1f8e4e
authored
May 08, 2018
by
David Caldwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastcgi: strip PATH_INFO from SCRIPT_FILENAME (mirroring SCRIPT_NAME)
parent
294f6957
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
caddyhttp/fastcgi/fastcgi.go
caddyhttp/fastcgi/fastcgi.go
+3
-4
caddyhttp/fastcgi/fastcgi_test.go
caddyhttp/fastcgi/fastcgi_test.go
+10
-0
No files found.
caddyhttp/fastcgi/fastcgi.go
View file @
5f1f8e4e
...
...
@@ -242,9 +242,6 @@ func (h Handler) exists(path string) bool {
func
(
h
Handler
)
buildEnv
(
r
*
http
.
Request
,
rule
Rule
,
fpath
string
)
(
map
[
string
]
string
,
error
)
{
var
env
map
[
string
]
string
// Get absolute path of requested resource
absPath
:=
filepath
.
Join
(
rule
.
Root
,
fpath
)
// Separate remote IP and port; more lenient than net.SplitHostPort
var
ip
,
port
string
if
idx
:=
strings
.
LastIndex
(
r
.
RemoteAddr
,
":"
);
idx
>
-
1
{
...
...
@@ -266,11 +263,13 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
docURI
:=
fpath
[
:
splitPos
+
len
(
rule
.
SplitPath
)]
pathInfo
:=
fpath
[
splitPos
+
len
(
rule
.
SplitPath
)
:
]
scriptName
:=
fpath
scriptFilename
:=
absPath
// Strip PATH_INFO from SCRIPT_NAME
scriptName
=
strings
.
TrimSuffix
(
scriptName
,
pathInfo
)
// SCRIPT_FILENAME is the absolute path of SCRIPT_NAME
scriptFilename
:=
filepath
.
Join
(
rule
.
Root
,
scriptName
)
// Add vhost path prefix to scriptName. Otherwise, some PHP software will
// have difficulty discovering its URL.
pathPrefix
,
_
:=
r
.
Context
()
.
Value
(
caddy
.
CtxKey
(
"path_prefix"
))
.
(
string
)
...
...
caddyhttp/fastcgi/fastcgi_test.go
View file @
5f1f8e4e
...
...
@@ -21,6 +21,7 @@ import (
"net/http/fcgi"
"net/http/httptest"
"net/url"
"path/filepath"
"strconv"
"sync"
"testing"
...
...
@@ -238,6 +239,15 @@ func TestBuildEnv(t *testing.T) {
envExpected
=
newEnv
()
envExpected
[
"SCRIPT_NAME"
]
=
"/test/fgci_test.php"
testBuildEnv
(
r
,
rule
,
fpath
,
envExpected
)
// 7. Test SCRIPT_NAME,SCRIPT_FILENAME do not include PATH_INFO
fpath
=
"/fgci_test.php/extra/paths"
r
=
newReq
()
envExpected
=
newEnv
()
envExpected
[
"PATH_INFO"
]
=
"/extra/paths"
envExpected
[
"SCRIPT_NAME"
]
=
"/fgci_test.php"
envExpected
[
"SCRIPT_FILENAME"
]
=
filepath
.
FromSlash
(
"/fgci_test.php"
)
testBuildEnv
(
r
,
rule
,
fpath
,
envExpected
)
}
func
TestReadTimeout
(
t
*
testing
.
T
)
{
...
...
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