fix(html): preserve the document around the rustmotion element - #255
Merged
Merged
Conversation
53 tasks
LeadcodeDev
force-pushed
the
fix/html-text-children
branch
from
September 22, 2026 06:11
8eb5453 to
7fced5c
Compare
LeadcodeDev
force-pushed
the
fix/html-writeback-preserve
branch
from
September 22, 2026 06:11
4216009 to
4ad7a5f
Compare
LeadcodeDev
force-pushed
the
fix/html-text-children
branch
from
September 22, 2026 08:35
7fced5c to
5b45306
Compare
LeadcodeDev
force-pushed
the
fix/html-writeback-preserve
branch
from
September 22, 2026 08:35
4ad7a5f to
ce389f3
Compare
LeadcodeDev
force-pushed
the
fix/html-text-children
branch
from
September 22, 2026 08:45
5b45306 to
6717eb1
Compare
LeadcodeDev
force-pushed
the
fix/html-writeback-preserve
branch
from
September 22, 2026 08:45
ce389f3 to
964b340
Compare
LeadcodeDev
changed the base branch from
fix/html-text-children
to
chantier/audit-2026-09
September 22, 2026 08:53
LeadcodeDev
force-pushed
the
fix/html-writeback-preserve
branch
from
September 22, 2026 09:01
964b340 to
e23b14f
Compare
All four write-back entry points (`set_inline_style`, `set_text_content`, `set_attribute`, `remove_inline_style`) re-serialize only the `<rustmotion>` element, and rustmotion-studio writes that string straight over the source file (editor/inspector.rs:2168 -> `write_and_note(path, &updated)`). Executed: a 281-byte document with `<!DOCTYPE html>`, `<html><head><meta charset="utf-8"></head><body>`, a leading `<!-- authored by hand -->` comment and a trailing comment becomes 150 bytes — doctype, head, meta, body and both outer comments gone — after one font-size tweak in the inspector. The transpiler happily accepts such documents (`find_element` is a document-wide DFS), so this is a supported authoring form being destroyed. The docstring's "formatting is normalized" does not cover deleting the surrounding document. Secondarily, `serialize_element` (lib.rs:488-497) does `let _ = serialize(...)` and `String::from_utf8(buf).unwrap_or_default()`, so a serializer failure would write an empty file rather than surface an error. Refs #220
LeadcodeDev
force-pushed
the
fix/html-writeback-preserve
branch
from
September 22, 2026 09:06
e23b14f to
92117e9
Compare
LeadcodeDev
added a commit
that referenced
this pull request
Sep 22, 2026
All four write-back entry points (`set_inline_style`, `set_text_content`, `set_attribute`, `remove_inline_style`) re-serialize only the `<rustmotion>` element, and rustmotion-studio writes that string straight over the source file (editor/inspector.rs:2168 -> `write_and_note(path, &updated)`). Executed: a 281-byte document with `<!DOCTYPE html>`, `<html><head><meta charset="utf-8"></head><body>`, a leading `<!-- authored by hand -->` comment and a trailing comment becomes 150 bytes — doctype, head, meta, body and both outer comments gone — after one font-size tweak in the inspector. The transpiler happily accepts such documents (`find_element` is a document-wide DFS), so this is a supported authoring form being destroyed. The docstring's "formatting is normalized" does not cover deleting the surrounding document. Secondarily, `serialize_element` (lib.rs:488-497) does `let _ = serialize(...)` and `String::from_utf8(buf).unwrap_or_default()`, so a serializer failure would write an empty file rather than surface an error. Refs #220
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Severity Medium, category correctness. Location:
crates/rustmotion-html/src/lib.rs:289Impact
All four write-back entry points (
set_inline_style,set_text_content,set_attribute,remove_inline_style) re-serialize only the<rustmotion>element, and rustmotion-studio writes that string straight over the source file (editor/inspector.rs:2168 ->write_and_note(path, &updated)). Executed: a 281-byte document with<!DOCTYPE html>,<html><head><meta charset="utf-8"></head><body>, a leading<!-- authored by hand -->comment and a trailing comment becomes 150 bytes — doctype, head, meta, body and both outer comments gone — after one font-size tweak in the inspector. The transpiler happily accepts such documents (find_elementis a document-wide DFS), so this is a supported authoring form being destroyed. The docstring's "formatting is normalized" does not cover deleting the surrounding document. Secondarily,serialize_element(lib.rs:488-497) doeslet _ = serialize(...)andString::from_utf8(buf).unwrap_or_default(), so a serializer failure would write an empty file rather than surface an error.Fix
Preserve the prologue/epilogue: record the byte span of the
<rustmotion>element in the original source and splice the re-serialized subtree back into it, or serialize the wholedom.documentincluding the doctype. Makeserialize_elementreturnResultand propagate failures so a write is never performed on a partial buffer. Add a round-trip test on a full document with doctype/head/body/comments.Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-12).