Skip to content

Surface unknown node types; escape rule interpolations - #72

Open
jpcamara wants to merge 2 commits into
mainfrom
feat/unknown-node-visibility
Open

Surface unknown node types; escape rule interpolations#72
jpcamara wants to merge 2 commits into
mainfrom
feat/unknown-node-visibility

Conversation

@jpcamara

Copy link
Copy Markdown
Owner

A custom editor node with no render rule doesn't break to_html — it quietly degrades: an unknown container renders its children without its own markup, and a node whose content lives only in its attributes renders nothing. Nothing reported that. This PR makes the degradation visible and hardens the escaping story around rules.

unknown_types

Y::Lexical#unknown_types / Y::ProseMirror#unknown_types (inherited by Y::Lexxy and Y::Tiptap): the node types the document contains whose handled is nil in node_types — exactly the set to_html degrades. It's the checklist companion to the existing discovery aid: render a real document from your editor in a test and assert the list is empty. Returns [] for a missing or wrong-shaped root, where to_html returns nil and nothing degrades.

Escaping

  • Y::Lexxy's list-item rule interpolated the stored __checked and __value attributes raw. Stored attributes are collaborator input — a crafted value could break out of the attribute position. Both now go through RenderRules.escape_attr. Legitimate editor values (booleans, integers) render byte-identically, so the parity fixtures are unaffected.
  • The renderer crates make escape_text / escape_attr public for splice callers, and both crate READMEs' callback examples now escape what they interpolate instead of demonstrating the unsafe pattern in a comment. lexical-yjs-html 0.1.1 → 0.1.2, prosemirror-yjs-html 0.1.2 → 0.1.3.

Docs

The crate READMEs and the root README's rules section state the degradation contract (unknown containers unwrap; attribute-only nodes render nothing; on the ProseMirror side, unknown marks render their text unformatted) and point at unknown_types.

Tests: unknown_types across all four renderers plus the rule-covered and missing-root cases; a hostile __checked value renders escaped. Crate doctests cover the updated README examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant