bug: trailing slash issue
manually writing a dir caused path traversal issues in the html so we force a trailing slash to prevent this
This commit is contained in:
@@ -152,6 +152,13 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append trailing slash to directories so rendered HTML has proper paths
|
||||||
|
if filestat.IsDir() && !strings.HasSuffix(r.URL.Path, "/") {
|
||||||
|
r.URL.Path += "/"
|
||||||
|
http.Redirect(w, r, r.URL.String(), http.StatusMovedPermanently)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Use Browser Cache (if possible)
|
// Use Browser Cache (if possible)
|
||||||
modtime := filestat.ModTime().UTC()
|
modtime := filestat.ModTime().UTC()
|
||||||
modhash := fmt.Sprint(modtime.Unix())
|
modhash := fmt.Sprint(modtime.Unix())
|
||||||
|
|||||||
Reference in New Issue
Block a user