@marcel91200 / caddy Mirror · read-only / commits / fa4cdde7
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

fastcgi: Make sure splitPos handles empty SplitPath correctly (#3491)

In commit f2ce81c, support for multiple path splitters was added. The type of SplitPath changed from string to []string, and splitPos was changed to loop through all values in SplitPath. Before that commit, if SplitPath was empty, strings.Index returned 0 and PATH_INFO was set correctly in buildEnv. Currently, however, splitPos returns -1 for empty values of SplitPath, behaving as if a split position could not be found at all. PATH_INFO is then never set in buildEnv and remains empty. Restore the old behaviour by explicitly checking whether SplitPath is empty and returning 0 in splitPos. Closes #3490

Wynn Wolf Arbor committed Jun 12, 2020 at 18:07 UTC fa4cdde7d8195f2e1ec5c937f00cbf9ce0d6537b
1 file changed +4
modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+4
@@ -303,6 +303,10 @@ func (t Transport) splitPos(path string) int {
303 // if httpserver.CaseSensitivePath {
304 // return strings.Index(path, r.SplitPath)
305 // }
306 + if len(t.SplitPath) == 0 {
307 + return 0
308 + }
309 +
310 lowerPath := strings.ToLower(path)
311 for _, split := range t.SplitPath {
312 if idx := strings.Index(lowerPath, strings.ToLower(split)); idx > -1 {