Skip to content

Fix profile render when the README.md size is larger than 1024 bytes #25131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 13, 2023
4 changes: 3 additions & 1 deletion modules/git/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/base64"
"io"

"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/typesniffer"
"code.gitea.io/gitea/modules/util"
)
Expand All @@ -21,13 +22,14 @@ func (b *Blob) Name() string {
}

// GetBlobContent Gets the content of the blob as raw text
// The max content size depends on MAX_DISPLAY_FILE_SIZE in app.ini
func (b *Blob) GetBlobContent() (string, error) {
dataRc, err := b.DataAsync()
if err != nil {
return "", err
}
defer dataRc.Close()
buf := make([]byte, 1024)
buf := make([]byte, setting.UI.MaxDisplayFileSize)
n, _ := util.ReadAtMost(dataRc, buf)
buf = buf[:n]
return string(buf), nil
Expand Down