From 1c0b2a3def5c96392038b4bcc9564c196d4cd30d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 2 Jan 2025 11:27:53 +0800 Subject: [PATCH] :bug: Query embed block scripts to be correctly escaped when exporting templates https://github.com/siyuan-note/siyuan/issues/13701 --- kernel/model/template.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/model/template.go b/kernel/model/template.go index 0388e1f8c..0f6596a1c 100644 --- a/kernel/model/template.go +++ b/kernel/model/template.go @@ -188,12 +188,16 @@ func DocSaveAsTemplate(id, name string, overwrite bool) (code int, err error) { return ast.WalkContinue } - // Code content in templates is not properly escaped https://github.com/siyuan-note/siyuan/issues/9649 + // Content in templates is not properly escaped + // https://github.com/siyuan-note/siyuan/issues/9649 + // https://github.com/siyuan-note/siyuan/issues/13701 switch n.Type { case ast.NodeCodeBlockCode: n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("""), []byte("\"")) case ast.NodeCodeSpanContent: n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("""), []byte("\"")) + case ast.NodeBlockQueryEmbedScript: + n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("""), []byte("\"")) case ast.NodeTextMark: if n.IsTextMarkType("code") { n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, """, "\"")