aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-06-13 18:02:25 +0900
committerGitHub <noreply@github.com>2023-06-13 09:02:25 +0000
commit22a39bb961daedccb08e47cb4cf83b2d4ef72108 (patch)
tree5a98a90df3293ea75754db5e64d4d7f5f43be9f5 /routers
parenta583c5630629fa664e77bad62afe95c0d9fb0a5e (diff)
downloadgitea-22a39bb961daedccb08e47cb4cf83b2d4ef72108.tar.gz
gitea-22a39bb961daedccb08e47cb4cf83b2d4ef72108.zip
Fix profile render when the README.md size is larger than 1024 bytes (#25131)
Fixes https://github.com/go-gitea/gitea/issues/25094 `GetBlobContent` will only get the first 1024 bytes, if the README.md size is larger than 1024 bytes, We can not render the rest of them. After this fix, we should provide the limited size to read when call `GetBlobContent`. After: ![image](https://github.com/go-gitea/gitea/assets/18380374/22a42936-4cf8-40b4-a5c7-e384082beb0d) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/view.go2
-rw-r--r--routers/web/user/profile.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 1d54f25884..cf719c49f0 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -363,7 +363,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
ctx.Data["FileError"] = ctx.Locale.Tr("actions.runs.invalid_workflow_helper", workFlowErr.Error())
}
} else if util.SliceContains([]string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}, ctx.Repo.TreePath) {
- if data, err := blob.GetBlobContent(); err == nil {
+ if data, err := blob.GetBlobContent(setting.UI.MaxDisplayFileSize); err == nil {
_, warnings := issue_model.GetCodeOwnersFromContent(ctx, data)
if len(warnings) > 0 {
ctx.Data["FileWarning"] = strings.Join(warnings, "\n")
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 42ae37e3ba..6f9f84d60d 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -107,7 +107,7 @@ func Profile(ctx *context.Context) {
}
blob, err := commit.GetBlobByPath("README.md")
if err == nil {
- bytes, err := blob.GetBlobContent()
+ bytes, err := blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
if err != nil {
ctx.ServerError("GetBlobContent", err)
return