{"record":{"id":"ef4f1686f6eae863","repo":"siyuan-note/siyuan","slug":"attribute-view-rich-text-style-entity-sentinel-was","errorCode":null,"errorMessage":"attribute view rich text style entity sentinel was not removed from node [%s]","messagePattern":"attribute view rich text style entity sentinel was not removed from node \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":2014,"sourceCode":"\t\t\t}\n\t\t\tnode.Tokens = []byte(literalReplacer.Replace(tokens))\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text node [%s]\", node.Type.String())\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\treturn ast.WalkContinue\n\t})\n\tif nil != err {\n\t\treturn\n\t}\n\tfor _, found := range restored {\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"attribute view rich text style entity was not restored\")\n\t\t}\n\t}\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif entering && valueTextRichNodeContainsSentinel(node, sentinel) {\n\t\t\terr = fmt.Errorf(\"attribute view rich text style entity sentinel was not removed from node [%s]\",\n\t\t\t\tnode.Type.String())\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\treturn ast.WalkContinue\n\t})\n\treturn\n}\n\nfunc valueTextRichNodeContainsSentinel(node *ast.Node, sentinel string) bool {\n\tvalues := []string{\n\t\tnode.ID, node.Spec, node.Data, string(node.Tokens), string(node.CodeBlockOpenFence),\n\t\tstring(node.CodeBlockInfo), string(node.CodeBlockCloseFence), string(node.LinkRefLabel),\n\t\tstring(node.FootnotesRefLabel), node.FootnotesRefId, string(node.HtmlEntityTokens),\n\t\tnode.TextMarkType, node.TextMarkAHref, node.TextMarkATitle, node.TextMarkInlineMathContent,\n\t\tnode.TextMarkInlineMemoContent, node.TextMarkBlockRefID, node.TextMarkBlockRefSubtype,\n\t\tnode.TextMarkFileAnnotationRefID, node.TextMarkFlashcardOcclusionID, node.TextMarkTextContent,\n\t}\n\tfor _, value := range values {","sourceCodeStart":1996,"sourceCodeEnd":2032,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/value.go#L1996-L2032","documentation":"Final safety pass: after restoration, a second AST walk found a node whose fields (tokens, text mark fields, IAL attributes, properties, IDs) still contain the sentinel string. Some sentinel survived the replacement replacers, meaning restoration did not fully rewrite the tree, so the library rejects the content rather than leaking private-use sentinel characters into stored rich text.","triggerScenarios":"Calling NormalizeValueTextRich / NormalizeRichContent on content where a sentinel appears in a node field the replacers do not rewrite, e.g. inside node.ID, TextMarkBlockRefID, an IAL attribute other than 'style', node properties, or a doubly-nested token that the replacer did not cover.","commonSituations":"Hand-crafted Kramdown with sentinels injected into block IDs or IAL attributes; content assembled by concatenating fragments from two different sanitization passes; adversarial/tampered payloads.","solutions":["Locate the sentinel in the offending node type and remove it manually or regenerate that portion of the content","Ensure the content never embeds private-use sentinel characters in IDs, IAL attributes, or mark metadata fields","Run the content through a full editor round-trip (DOM -> Kramdown) which rebuilds all fields from scratch","Restore the value from a known-good history entry"],"exampleFix":"// before: sentinel in IAL\n{: id=\"...\" style=\"x \\ue000siyuan-av-rich-text-style-entities-0\\ue002 y\"}\n// after\n{: style=\"color: var(--b3-font-color1);\"}","handlingStrategy":"validation","validationCode":"// reject sentinels anywhere outside restored mark/token fields\nconst sentinel = \"\\ue000siyuan-av-rich-text-style-entities\";\nif (blockId.includes(sentinel) || JSON.stringify(ial).includes(sentinel)) {\n  throw new Error(\"sentinel leaked into ID or IAL attribute\");\n}","typeGuard":null,"tryCatchPattern":"try { save(value) } catch (e) { if (String(e).includes(\"sentinel was not removed\")) { value = regenerateViaRoundTrip(value); retry(); } }","preventionTips":["Never inject sentinel strings into IDs, IAL attributes, or mark metadata","Assemble rich text only through the official normalization pipeline","Treat U+E000-U+E002 characters as reserved and strip them from user input"],"tags":["attribute-view","rich-text","sanitization","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}