mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-06-10 13:30:49 +00:00
Don't serve files for URLs with trailing slashes.
Fixes: https://codeberg.org/git-pages/git-pages/issues/205
This commit is contained in:
+5
-1
@@ -298,7 +298,8 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
|
||||
reader := io.ReadSeeker(nil)
|
||||
mtime := time.Time{}
|
||||
for {
|
||||
entryPath, _ = strings.CutSuffix(entryPath, "/")
|
||||
endsInSlash := false
|
||||
entryPath, endsInSlash = strings.CutSuffix(entryPath, "/")
|
||||
entryPath, err = ExpandSymlinks(manifest, entryPath)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -306,6 +307,9 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
|
||||
return err
|
||||
}
|
||||
entry = manifest.Contents[entryPath]
|
||||
if entry != nil && IsEntryRegularFile(entry) && endsInSlash {
|
||||
entry = nil
|
||||
}
|
||||
if !appliedRedirect {
|
||||
redirectKind := RedirectAny
|
||||
if entry != nil && entry.GetType() != Type_InvalidEntry {
|
||||
|
||||
Reference in New Issue
Block a user