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
caddyhttp: Corrected host label index check (fix #3502)
Matthew Holt committed
Jun 30, 2020 at 11:42 UTC
77f233a4840afb8b081d12b083b19ed314fd975a
2 files changed
+5
-1
modules/caddyhttp/replacer.go
+1
-1
@@ -172,7 +172,7 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
172
reqHost = req.Host // OK; assume there was no port
173
}
174
hostLabels := strings.Split(reqHost, ".")
175
- if idx > len(hostLabels) {
175
+ if idx >= len(hostLabels) {
176
return "", true
177
}
178
return hostLabels[len(hostLabels)-idx-1], true
modules/caddyhttp/replacer_test.go
+4
@@ -107,6 +107,10 @@ eqp31wM9il1n+guTNyxJd+FzVAH+hCZE5K+tCgVDdVFUlDEHHbS/wqb2PSIoouLV
107
input: "{http.request.host.labels.1}",
108
expect: "example",
109
},
110
+ {
111
+ input: "{http.request.host.labels.2}",
112
+ expect: "<empty>",
113
+ },
114
{
115
input: "{http.request.tls.cipher_suite}",
116
expect: "TLS_AES_256_GCM_SHA384",