Skip to content

fix(fs): identify SVG by its document root - #1184

Merged
Rinat S (rsolmano) merged 4 commits into
JetBrains:mainfrom
Afloat16:fix/svg-root-detection-20261103
Nov 6, 2026
Merged

Rinat S (rsolmano) merged 4 commits into
JetBrains:mainfrom
Afloat16:fix/svg-root-detection-20261103

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

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

  • Before the fix: 2 regression tests failed on main.
  • Targeted source suite: 10 tests passed using Node and Vitest 4.1.11 with bun:test aliased to Vitest; test assertions and production source were unchanged by the runner.
  • Test file: packages/server/src/fs/content.test.ts.
  • Biome 2.5.0 check of changed TypeScript files and git diff --check: passed.
  • Bun aborts at process startup in this environment. The complete Bun lint/typecheck/test gates and no-agent E2E suite could not run.

Checklist

  • Fast gates pass: bun run lint, bun run typecheck, bun run test
  • E2E suite passes for app-affecting changes (bun run e2e, or bun run e2e:full when touching agent behavior)
  • Before/after screenshots are included for frontend changes, or marked not applicable
  • Relevant SPEC.md / top-level specs updated to reflect any boundary, contract, or behavior change
  • I have read the Contributing guide and agree to the Code of Conduct

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Walking past prolog, comments, PIs and doctype to the real root element is much more robust than the old regex.

@OLavrik
Olga Lavrichenko (OLavrik) added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 5, 2026
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.
@Afloat16

Copy link
Copy Markdown
Contributor Author

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 content.test.ts passes 12 tests on Node 24.22.1 / Vitest 4.1.11, using the same external bun:test import alias as the original validation; production source and test assertions are unchanged by the runner. Biome 2.5.0 checks and git diff --check also pass. Native Bun 1.4.4 still aborts during direct test/E2E startup in this environment, so full native gates remain for hosted CI.

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?

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@rsolmano
Rinat S (rsolmano) added this pull request to the merge queue Nov 6, 2026
Merged via the queue into JetBrains:main with commit d39ef8b Nov 6, 2026
11 checks passed
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.

3 participants