Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2026-01-31 18:02:31 +08:00
commit 78b7f86921
3 changed files with 63 additions and 3 deletions

View file

@ -63,7 +63,7 @@ export const initAbout = () => {
<div class="b3-label">
${window.siyuan.languages.about2}
<div class="fn__hr"></div>
<a target="_blank" href="${"http://127.0.0.1:" + location.port}" class="b3-button b3-button--outline fn__block">
<a target="_blank" href="${"http://127.0.0.1:" + location.port}?openExternal" class="b3-button b3-button--outline fn__block">
<svg><use xlink:href="#iconLink"></use></svg>${window.siyuan.languages.about4}
</a>
<div class="b3-label__text">${window.siyuan.languages.about3.replace("${port}", location.port)}</div>

View file

@ -252,7 +252,7 @@ func prepareWriteTree(tree *parse.Tree) (data []byte, filePath string, err error
tree.Root.SetIALAttr("type", "doc")
renderer := render.NewJSONRenderer(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
data = renderer.Render()
data = bytes.ReplaceAll(data, []byte(`\u0000`), []byte(""))
data = removeUnescapedUnicodeNull(data)
if !util.UseSingleLineSave {
buf := bytes.Buffer{}
buf.Grow(1024 * 1024 * 2)
@ -269,6 +269,46 @@ func prepareWriteTree(tree *parse.Tree) (data []byte, filePath string, err error
return
}
// removeUnescapedUnicodeNull 只移除未被转义的 `\u0000` 字面序列。
// 判断方法:在匹配到 `\u0000` 时向前数连续的 `\` 个数,若为偶数则视为未转义并移除。
func removeUnescapedUnicodeNull(data []byte) []byte {
patLen := 6 // len(`\u0000`)
n := len(data)
if n < patLen {
return data
}
dst := make([]byte, 0, n)
i := 0
for i < n {
// 快速检查是否可能匹配 `\u0000`
if i+patLen <= n &&
data[i] == '\\' &&
data[i+1] == 'u' &&
data[i+2] == '0' &&
data[i+3] == '0' &&
data[i+4] == '0' &&
data[i+5] == '0' {
// 统计当前 `\` 之前连续的反斜杠数量
j := i - 1
backslashes := 0
for j >= 0 && data[j] == '\\' {
backslashes++
j--
}
// 若为偶数,则当前 `\` 未被转义,跳过整个 `\u0000`
if backslashes%2 == 0 {
i += patLen
continue
}
}
// 否则保留当前字节
dst = append(dst, data[i])
i++
}
return dst
}
func afterWriteTree(tree *parse.Tree) {
docIAL := parse.IAL2MapUnEsc(tree.Root.KramdownIAL)
cache.PutDocIAL(tree.Path, docIAL)

View file

@ -3111,8 +3111,28 @@ func getKanbanPreferredGroupKey(attrView *av.AttributeView) (ret *av.Key) {
break
}
}
if nil == ret {
ret = attrView.GetBlockKey()
name := av.GetAttributeViewI18n("select")
ret = av.NewKey(ast.NewNodeID(), name, "", av.KeyTypeSelect)
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: ret})
for _, view := range attrView.Views {
newField := &av.BaseField{ID: ret.ID}
if nil != view.Table {
newField.Wrap = view.Table.WrapField
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{BaseField: newField})
}
if nil != view.Gallery {
newField.Wrap = view.Gallery.WrapField
view.Gallery.CardFields = append(view.Gallery.CardFields, &av.ViewGalleryCardField{BaseField: newField})
}
if nil != view.Kanban {
newField.Wrap = view.Kanban.WrapField
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: newField})
}
}
}
return
}