Skip to content

Match HTML and XHTML from opening tags - #158

Merged
jeremy merged 1 commit into
security/harden-table-generationfrom
security/html-svg-magic
Aug 19, 2026
Merged

jeremy merged 1 commit into
security/harden-table-generationfrom
security/html-svg-magic

Conversation

@jeremy

@jeremy jeremy commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Stacked on #157.

This replaces broad HTML and XHTML signatures with bounded rules anchored to the document opening.

  • Container formats keep their structural type when markup appears later.
  • XHTML requires the XHTML namespace and accepts comments around the opening declaration.
  • XML-prefixed SVG is detected when its root element follows a short XML declaration.
  • require "marcel" and require "marcel/magic" install the same rules.
  • Generated tables keep the extensions but omit the old broad signatures.

A valid MIDI text event containing markup remains audio/midi. With content-only detection, bare HTML fragments now return application/octet-stream; filename hints still apply through MimeType.for. This also covers the partial-read case from #153.

Marcel labels content; it does not sanitize HTML.

@jeremy
jeremy force-pushed the security/html-svg-magic branch from 796879a to 0557dd0 Compare August 18, 2026 09:36
@jeremy jeremy changed the title Anchor HTML detection to opening markers in the initial sample Match HTML and XHTML from opening tags Aug 18, 2026
@jeremy
jeremy force-pushed the security/html-svg-magic branch from 0557dd0 to 1afd3b1 Compare August 18, 2026 09:40
Use bounded opening-tag rules, remove the broader generated matches, and register the rules for both top-level and direct Magic loading. Preserve structural formats when markup appears later in their content.
@jeremy
jeremy force-pushed the security/html-svg-magic branch from 1afd3b1 to 9db5f70 Compare August 18, 2026 18:28
@jeremy
jeremy merged commit 885dde8 into main Aug 19, 2026
24 checks passed
@jeremy
jeremy deleted the security/html-svg-magic branch August 19, 2026 20:16
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