Skip to content

Release v2.0.0

Choose a tag to compare

@EmilStenstrom EmilStenstrom released this 24 May 21:09
· 312 commits to main since this release

Changed

  • BREAKING: Sanitization is now HTML-only. SVG and MathML are still parsed and tree-built when sanitization is disabled, but sanitizer output always drops foreign-namespace content. SanitizationPolicy.drop_foreign_namespaces has been removed.
    This removes a high-risk configuration surface where custom policies could preserve SVG/MathML while relying on JustHTML to understand every browser-active foreign-content feature. Recent hardening had to special-case SVG animation values, presentation attributes with url(...), MathML URL attributes, foreign integration points, and mutation-XSS stabilization. Making sanitized output HTML-only gives the sanitizer one reviewable security model: foreign content can still be parsed for correctness, but it is not emitted from untrusted sanitization pipelines.
  • BREAKING: Remove the public tokenizer_opts and tree_builder constructor hooks from JustHTML(...). These were internal parser injection points rather than supported application configuration.
  • BREAKING: Remove to_test_format from the top-level justhtml export. The html5lib fixture formatter remains available from justhtml.serialize for tests and conformance tooling.
  • BREAKING: Remove the deprecated safe= alias from JustHTML(...); use sanitize= instead.
  • BREAKING: Remove the public RewriteAttrs alias; use EditAttrs instead.
  • Reorganize the old top-level implementation modules into packages and normalize several package names. Code that stays on the public from justhtml import ... API is unaffected. Direct module-path imports are internal implementation details, are not a supported stability surface, and may change without compatibility guarantees.

Security

  • (Severity: Low) Replace undefined Windows-1252 bytes during byte-input decoding instead of raising UnicodeDecodeError. Previously, untrusted byte input containing values such as 0x81 could crash parsing before sanitization.
  • (Severity: Low) Reject ambiguous comma or semicolon delimiters inside allowlisted meta-refresh URL targets. Previously, custom policies that allowed <meta http-equiv="refresh" content="..."> could preserve refresh values with extra delimiter text after a validated URL.
  • (Severity: Low) Validate srcset descriptors while sanitizing URL candidates. Previously, descriptor text after an allowed srcset URL was preserved without checking that it was a valid width or density descriptor.
  • (Severity: Low) Harden documentation search result rendering by escaping result titles and restricting indexed result links to same-origin documentation HTML pages. Previously, titles derived from same-origin documentation pages were inserted through innerHTML without escaping, and generated result links trusted any .html href discovered in the docs index.