Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/18049

Danielc368e49e80b4
diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go
index 24c268b034..45102b45f2 100644
--- a/kernel/treenode/node.go
+++ b/kernel/treenode/node.go
@@ -196,9 +196,9 @@ func IsNodeOCRed(node *ast.Node) (ret bool) {
func GetNodeSrcTokens(n *ast.Node) (ret string) {
if index := bytes.Index(n.Tokens, []byte("src=\"")); 0 < index {
src := n.Tokens[index+len("src=\""):]
- if index = bytes.Index(src, []byte("\"")); 0 < index {
- src = src[:bytes.Index(src, []byte("\""))]
- ret = strings.TrimSpace(string(src))
+ if closeQuote := bytes.Index(src, []byte("\"")); -1 < closeQuote {
+ // src 为空时闭合引号紧随其后,closeQuote 为 0 也是合法情况
+ ret = strings.TrimSpace(string(src[:closeQuote]))
return
}