]> source.dussan.org Git - gitea.git/commitdiff
Fix citation error when the file size is larger than 1024 bytes (#27958) (#27965)
authorGiteabot <teabot@gitea.io>
Wed, 8 Nov 2023 14:45:57 +0000 (22:45 +0800)
committerGitHub <noreply@github.com>
Wed, 8 Nov 2023 14:45:57 +0000 (22:45 +0800)
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

index 9085bda395f150c66b2df20469e7879b9fc0acdb..3ea11943d6c4a408b0eeda52426924fc662e8196 100644 (file)
@@ -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
                }
        }