Repository navigation
fix(fs): identify SVG by its document root - #1184
Conversation
Olga Lavrichenko (OLavrik)
left a comment
There was a problem hiding this comment.
Thanks! Walking past prolog, comments, PIs and doctype to the real root element is much more robust than the old regex.
Resolve the adjacent specification and test conflicts while retaining the reviewed SVG root detection and the AVIF compatible-brand handling from main. Keep both sets of regression tests and their documented boundaries.
|
Thanks for the review. Resolved the merge-queue conflict in 4016638 by merging main at b91834a. The reviewed SVG logic and regressions are preserved together with the AVIF handling and tests merged in #1185. The PR still changes only the original three fs files, and GitHub now reports no merge conflict. The combined The new-head CI run is awaiting maintainer approval. Could you approve it and re-add the PR to the merge queue once the checks pass? |
Problem
After an XML declaration, the current content classifier treats any later
<svg>as the document root. XML containing a nested SVG or a quoted example is sent to the image renderer. Valid SVG files with a leading comment or an empty<svg/>root can instead miss image classification.Approach
Inspect the first element after XML declarations, comments, processing instructions and a doctype, within the existing 8 KiB sniff window. Doctype scanning preserves quoted greater-than characters and internal subsets. The SVG name match also accepts the empty-element form.
Changes
Add root-versus-descendant regressions, valid prologue cases, and malformed-prefix controls. Update the fs specification.
Screenshots
Not applicable — no frontend changes.
Validation
bun:testaliased to Vitest; test assertions and production source were unchanged by the runner.packages/server/src/fs/content.test.ts.git diff --check: passed.Checklist
bun run lint,bun run typecheck,bun run testbun run e2e, orbun run e2e:fullwhen touching agent behavior)SPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior change