Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Prevent modification of the `data-task` attribute https://github.com/siyuan-note/siyuan/issues/17343#issuecomment-4223807048 (#17466)

Jeffrey Chen8f3b9992c2b3
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index 5a715fcd87..43586cac5d 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -216,12 +216,16 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[s
err = errors.New(Conf.Language(25) + " [" + node.ID + "]")
return
}
+ if lowerName == "data-task" {
+ err = errors.New(`setting or removing [data-task] attribute is not allowed via this interface. Please use "/api/block/updateTaskListItemMarker" or "/api/block/batchUpdateTaskListItemMarker" to update the task list item marker`)
+ return
+ }
// 处理文档标签 https://github.com/siyuan-note/siyuan/issues/13311
if lowerName == "tags" {
var tags []string
- tmp := strings.Split(value, ",")
- for _, t := range tmp {
+ tmp := strings.SplitSeq(value, ",")
+ for t := range tmp {
t = strings.TrimSpace(t)
if "" != t {
tags = append(tags, t)
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 644a5c7864..4144956df7 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1767,23 +1767,9 @@ func (tx *Transaction) doSetAttrs(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
}
- var invalidNames []string
- for name := range attrs {
- if !isValidAttrName(name) {
- logging.LogWarnf("invalid attr name [%s]", name)
- invalidNames = append(invalidNames, name)
- }
- }
- for _, name := range invalidNames {
- delete(attrs, name)
- }
-
- for name, value := range attrs {
- if "" == value {
- node.RemoveIALAttr(name)
- } else {
- node.SetIALAttr(name, value)
- }
+ if _, setErr := setNodeAttrs0(node, attrs); nil != setErr {
+ logging.LogErrorf("set attrs failed: %s", setErr)
+ return &TxErr{code: TxErrCodePushMsg, msg: setErr.Error(), id: id}
}
tx.writeTree(tree)