mirror of
https://tildegit.org/solderpunk/molly-brown.git
synced 2025-04-13 09:29:46 +00:00
Fix infinite redirect bug.
Previously, URLs without trailing slashes in the path which resolved to directories caused infinite redirects if there was anything in the URL after the path (like a query). Thanks to both Luke Emmet and Stephane Bortzmeyer for reporting this!
This commit is contained in:
parent
3d4d830e98
commit
e06f8bddbc
1 changed files with 2 additions and 1 deletions
|
@ -205,7 +205,8 @@ func serveDirectory(URL *url.URL, path string, log *LogEntry, conn net.Conn, con
|
||||||
// Redirect to add trailing slash if missing
|
// Redirect to add trailing slash if missing
|
||||||
// (otherwise relative links don't work properly)
|
// (otherwise relative links don't work properly)
|
||||||
if !strings.HasSuffix(URL.Path, "/") {
|
if !strings.HasSuffix(URL.Path, "/") {
|
||||||
conn.Write([]byte(fmt.Sprintf("31 %s\r\n", URL.String()+"/")))
|
URL.Path += "/"
|
||||||
|
conn.Write([]byte(fmt.Sprintf("31 %s\r\n", URL.String())))
|
||||||
log.Status = 31
|
log.Status = 31
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue