mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
fix: preserve IPv6 brackets in redirects
Re-wrap bare IPv6 hosts after stripping ports so HTTPS redirect URLs stay valid. Add a regression test covering bracketed IPv6 hosts in redirect responses.
This commit is contained in:
parent
9e57f5a5f5
commit
121679b44e
2 changed files with 23 additions and 0 deletions
3
serve.go
3
serve.go
|
|
@ -332,6 +332,9 @@ func buildRedirectServer(engine *Engine, cfg runConfig) (*http.Server, error) {
|
|||
|
||||
if parsedHost, _, err := net.SplitHostPort(host); err == nil {
|
||||
host = parsedHost
|
||||
if strings.Contains(host, ":") && !strings.HasPrefix(host, "[") {
|
||||
host = "[" + host + "]"
|
||||
}
|
||||
}
|
||||
|
||||
targetURL := "https://" + host
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue