From 824d40edc6630bfb1a288760ef902adab33d7d9d Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 8 Nov 2023 22:45:57 +0800 Subject: [PATCH] Fix citation error when the file size is larger than 1024 bytes (#27958) (#27965) Backport #27958 by @yp05327 Mentioned in: https://github.com/go-gitea/gitea/pull/27931#issuecomment-1798016960 Same to #25131, so use the same method to fix this problem. Co-authored-by: yp05327 <576951401@qq.com> --- 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 9085bda395f1..3ea11943d6c4 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -711,14 +711,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 } }