Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var cStringHTTPMethods = map[string]*C.char{
// Inspired by https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
func addKnownVariablesToServer(fc *frankenPHPContext, trackVarsArray *C.zval) {
request := fc.request
// Separate remote IP and port; more lenient than net.SplitHostPort
ip, port := splitRemoteAddr(request.RemoteAddr)

var rs, https, sslProtocol *C.zend_string
Expand Down
3 changes: 3 additions & 0 deletions cgi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ func TestSplitRemoteAddr(t *testing.T) {
{"ipv6 zone bracketed with port", "[fe80::1%eth0]:443", "fe80::1%eth0", "443"},
{"ipv4 without port", "192.168.0.1", "192.168.0.1", ""},
{"empty", "", "", ""},
{"only colon", ":", "", ""},
// Must not panic: would crash the process via the cgo callback.
{"lone open bracket", "[", "[", ""},
{"open bracket with port", "[:9000", "[", "9000"},
{"empty brackets", "[]", "", ""},
{"opening bracket with colon", "[:", "[", ""},
{"unterminated bracket with port", "[::1:80", "[::1", "80"},
}

for _, tt := range tests {
Expand Down
Loading