fix: disallow blame on directories (#6716)

- Don't allow the blame operation on directories.
- Added integration test.
- Resolves forgejo/forgejo#6533

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6716
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-01-29 09:02:46 +00:00 committed by Gusted
parent b69755b417
commit fd285bfc4e
2 changed files with 17 additions and 0 deletions

View file

@ -56,6 +56,11 @@ func RefBlame(ctx *context.Context) {
HandleGitError(ctx, "Repo.Commit.GetTreeEntryByPath", err)
return
}
if entry.IsDir() {
ctx.NotFound("Cannot blame directory", nil)
return
}
blob := entry.Blob()
ctx.Data["PageIsViewCode"] = true