🎨 Limit the database title to 256 characters https://github.com/siyuan-note/siyuan/issues/15459

This commit is contained in:
Daniel 2025-08-07 10:35:40 +08:00
parent 3d9b0bfa6f
commit 0d3a2479cb
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 13 additions and 0 deletions

View file

@ -2922,6 +2922,10 @@ func (tx *Transaction) setAttributeViewName(operation *Operation) (err error) {
}
attrView.Name = strings.TrimSpace(operation.Data.(string))
attrView.Name = strings.ReplaceAll(attrView.Name, "\n", " ")
if 256 < len(attrView.Name) {
attrView.Name = gulu.Str.SubStr(attrView.Name, 256)
}
err = av.SaveAttributeView(attrView)
_, nodes := tx.getAttrViewBoundNodes(attrView)

View file

@ -17,7 +17,9 @@
package model
import (
"strings"
"time"
"unicode/utf8"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
@ -93,6 +95,13 @@ func checkAttrView(attrView *av.AttributeView, view *av.View) {
}
}
// 截断超长的数据库标题 Limit the database title to 256 characters https://github.com/siyuan-note/siyuan/issues/15459
if 256 < utf8.RuneCountInString(attrView.Name) {
attrView.Name = strings.ReplaceAll(attrView.Name, "\n", " ")
attrView.Name = gulu.Str.SubStr(attrView.Name, 256)
changed = true
}
if changed {
av.SaveAttributeView(attrView)
}