This commit is contained in:
Daniel 2024-09-27 00:05:48 +08:00
parent 459b700e26
commit 800dec29df
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 12 additions and 3 deletions

View File

@ -118,6 +118,10 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
}
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
return
}
srcTree, _ := LoadTreeByBlockID(srcID)
if nil == srcTree {
err = ErrBlockNotFound
@ -136,9 +140,14 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
}
}
if nil == treenode.GetBlockTree(targetID) {
// 目标块不存在时忽略处理
return
}
targetTree, _ := LoadTreeByBlockID(targetID)
if nil == targetTree {
err = ErrBlockNotFound
// 目标块不存在时忽略处理
return
}

View File

@ -203,8 +203,8 @@ func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
}
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
if "" == id {
logging.LogErrorf("block id is empty")
if !ast.IsNodeIDPattern(id) {
logging.LogErrorf("block id is invalid [id=%s]", id)
return nil, ErrTreeNotFound
}