Skip to content

fix(lint): a file with markup hidden in an svg title is reported as a lint error, not a crash - #8823

Open
miguel-heygen wants to merge 13 commits into
mainfrom
fix/lint-reports-unreadable-html
Open

miguel-heygen wants to merge 13 commits into
mainfrom
fix/lint-reports-unreadable-html

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

hyperframes lint now lists a file it cannot read the way a browser does as one error, html_read_unlike_browser, instead of stopping with that error. Every other file in the project is still linted. Checks that span the whole project (shared audio, missing assets, sub-composition use) are skipped while a mounted file is unreadable, because each of them reads every mounted file.

Why

Since #8760, the shared HTML reader (@hyperframes/parsers/linkedom) refuses HTML whose title, style, script, textarea or xmp inside an <svg> or <math> element holds tags or comments, which a browser reads as different markup. Lint reads through the same reader, so on such a file hyperframes lint printed only the refusal and listed nothing, where before it listed the project's findings.

Related work

Follows #8760, which added the refusal. This branch is stacked on it.

How

  • refusedFinding(html) in packages/lint/src/hyperframeLinter.ts asks the shared reader and turns its refusal, and only that error, into an error finding. The reader still decides what is refused.
  • lintHyperframeHtml returns that finding alone for such a page.
  • lintProject (packages/lint/src/project.ts) does not read into an unreadable file (mountedSources, linkedSources, the font and composition lists). When any mounted file is unreadable, each one is reported once and the project-wide checks are skipped.
  • docs/reference/lint-rules.mdx describes the new code.

Visible change

hyperframes lint on such a project:

Before: the command prints the bare error message, This HTML has tags or comments inside an SVG or MathML title, ..., and stops.

After:

◆  Linting lintproj/index.html

  ✗ html_read_unlike_browser: This HTML has tags or comments inside an SVG or MathML title, style, script, textarea or xmp element, which can't be read the way a browser reads them.

◇  1 error(s), 0 warning(s)

Both exit 1.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

fails without the fix: with the lint sources before this change, all 4 new tests fail: in packages/lint/src/hyperframeLinter.test.ts, returns the refusal as its one error finding, instead of throwing; in packages/lint/src/project.test.ts, reports a root page it cannot read as one error, instead of stopping, reports a mounted composition it cannot read, and still lints the root and reports a mounted file outside compositions/ that it cannot read. With the fix they pass 3 runs in a row. The full lint suite passes (30 files, 1363 tests) and the lint type check is clean. The before and after output above is bun packages/cli/src/cli.ts lint <project> from source on a one-file project.

# Conflicts:
#	scripts/package-size-budgets.json
# Conflicts:
#	packages/cli/src/capture/captureImageValidation.ts
#	packages/cli/src/capture/filterExtractedScripts.ts
#	packages/cli/src/capture/iconClassifier.ts
#	packages/cli/src/cloud/offload.ts
#	packages/cli/src/cloud/offloadTrim.ts
#	packages/cli/src/commands/add.ts
#	packages/cli/src/commands/media-treatment.ts
#	packages/cli/src/commands/snapshot.ts
#	packages/cli/src/commands/snapshotHeldVideos.ts
#	packages/cli/src/commands/snapshotReview.ts
#	packages/cli/src/commands/snapshotSampling.ts
#	packages/cli/src/media-use/lib/svg-sanitize.mjs
#	packages/cli/src/utils/checkAudio.ts
#	packages/cli/src/utils/compositionCensus.ts
#	packages/cli/src/utils/compositionFps.ts
#	packages/cli/src/utils/compositionViewport.ts
#	packages/cli/src/utils/dom.ts
#	packages/cli/src/utils/fileReferences.ts
#	packages/cli/src/utils/mediaUsedSeconds.ts
#	packages/cli/src/utils/publishProject.ts
#	packages/cli/src/utils/publishProxyBake.ts
#	packages/cli/src/whisper/normalize.ts
#	packages/core/src/compiler/htmlDocument.ts
#	packages/core/src/compiler/htmlParityContract.ts
#	packages/core/src/compiler/standaloneEntry.ts
#	packages/core/src/figma/sanitizeSvg.ts
#	packages/core/src/fonts/pageTree.ts
#	packages/core/src/generators/richTextHtml.ts
#	packages/engine/src/services/audioMixer.ts
#	packages/engine/src/services/videoFrameExtractor.ts
#	packages/parsers/package-subpaths.json
#	packages/parsers/package.json
#	packages/parsers/src/hfIds.ts
#	packages/parsers/src/timingMismatches.ts
#	packages/parsers/tsup.config.ts
#	packages/producer/src/services/animatedGifPrep.ts
#	packages/producer/src/services/compilationTester.ts
#	packages/producer/src/services/heifImagePrep.ts
#	packages/producer/src/services/htmlCompiler.ts
#	packages/producer/src/services/render/stages/probeStage.ts
#	packages/producer/src/services/render/videoFrameCoverage.ts
#	packages/producer/src/services/renderMediaCollector.ts
#	packages/studio-server/src/helpers/captureVideos.ts
#	packages/studio-server/src/helpers/compositionInputs.ts
#	packages/studio-server/src/helpers/compositionInsertion.ts
#	packages/studio-server/src/helpers/lazyPreviewImages.ts
#	packages/studio-server/src/helpers/previewReads.ts
#	packages/studio-server/src/helpers/sourceMutation.ts
#	packages/studio-server/src/helpers/subComposition.ts
#	packages/studio-server/src/routes/files.ts
#	packages/studio-server/src/routes/preview.ts
#	scripts/package-size-budgets.json
Base automatically changed from fix/duplicate-svg-title to main November 25, 2026 06:52
@mintlify

mintlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
hyperframes 🟢 Ready View Preview Nov 25, 2026, 9:56 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 53 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@miguel-heygen
miguel-heygen marked this pull request as ready for review November 25, 2026 07:09
@miguel-heygen
miguel-heygen marked this pull request as draft November 25, 2026 07:09

@terencecho terencecho 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.

P2 — A parser refusal can still abort the whole lint run for a mounted file with a URL-encoded path (packages/lint/src/project.ts:359). mountedSources resolves the literal attribute with path.resolve, but the project-wide audio walk at lines 949–953 uses resolveCompositionSrc, which decodes URL paths. For example, a scene with an ordinary space in its filename can be missed by the unreadable-file preflight and still be opened by the audio walk. If the parser refuses that file, the walk throws and the CLI discards the findings collected so far.

Use the same composition path resolver for discovery and the project-wide walks. Add coverage for a mounted filename with a URL-encoded space and check that the lint report still includes the root findings.

The PR body names the fail-first tests. This finding is from static review.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Fixed in b2e8757. mountedSources (packages/lint/src/project.ts) now resolves data-composition-src with resolveCompositionSrc, the resolver the project-wide audio walk, the sub-composition check and the renderer use. So the unreadable-file check reads exactly the files those walks open. It still returns null for a path that leaves the project.

New test in packages/lint/src/project.test.ts: finds a mounted file it cannot read by the name the renderer opens, URL-encoded or not. The root mounts compositions/my%20scene.html, and compositions/my scene.html holds HTML the parser refuses. Before the fix, lint threw HtmlReadUnlikeBrowserError and listed nothing. With it, the report has one html_read_unlike_browser error for compositions/my scene.html and still includes index.html.

The full lint suite passes 3 runs in a row (30 files, 1364 tests), and the core, studio and scripts type checks are clean.

@terencecho terencecho 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.

P2 — packages/lint/src/project.ts:357. The shared resolver closes the encoded-filename case. Mount discovery still applies the raw reference length limit while the duplicate-audio walk at line 949 resolves without that limit. The walks can disagree about which file to inspect because the resolver normalizes the reference. A parser refusal in a file skipped by discovery can still abort the report. Please share the mount eligibility check between the two walks.

Static review only. The diff check passed.

— tai (automated review)

This branch was successfully deployed

1 active (outdated) deployment
staging - docs — cd121007 Deployed Nov 25, 2026 by mintlify[bot]
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.

2 participants