From f48a863b99a8075da290f9dc85d8296c974fb86b Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Wed, 8 Nov 2023 15:40:12 +0900 Subject: [PATCH] Fix citation error when the file size is larger than 1024 bytes (#27958) Mentioned in: https://github.com/go-gitea/gitea/pull/27931#issuecomment-1798016960 Same to #25131, so use the same method to fix this problem. --- routers/web/repo/view.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 4dfa01d8e2..89bb1839e1 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -716,14 +716,11 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) { return } defer dataRc.Close() - buf := make([]byte, 1024) - n, err := util.ReadAtMost(dataRc, buf) + ctx.PageData["citationFileContent"], err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize) if err != nil { - ctx.ServerError("ReadAtMost", err) + ctx.ServerError("GetBlobContent", err) return } - buf = buf[:n] - ctx.PageData["citationFileContent"] = string(buf) break } }