Skip to content

v1.0.0

Choose a tag to compare

@github-actions github-actions released this 17 Oct 19:32
· 104 commits to main since this release
c18f33c

The 1.0.0 hardening release. Everything under Breaking needs a change in code that
calls the API; MIGRATION.md shows each one, before and after. Issue
numbers are in micheltlutz/molt.

Breaking

  • Node is #[non_exhaustive], and Node::Text, Node::Raw and Node::Comment hold a
    Markup, a string with no public constructor. Node::Text("<script>".into()) no longer
    compiles; build nodes with Node::text (escapes), Node::comment (neutralises) and
    Node::raw (the greppable hatch). A match on Node needs a _ arm.
    (#13,
    #14)
  • #[non_exhaustive] on Role, A11yIssue, RenderOptions, Document, SitemapUrl,
    RssItem and RssGenerator: build them with their constructors, not struct literals.
  • RenderOptions::indent is private. Read it with indent(); with_indent keeps only
    spaces and tabs, at most 16. (#28)
  • Layout::render and Layout::render_many are wrap and wrap_many, because they
    collided with Render::render. (#18)
  • escape_text, escape_text_with_slashes, escape_attribute and escape_xml return
    Cow<str>
    , borrowed when nothing needed escaping.
    (#21)
  • VOID_TAGS and WHITESPACE_SENSITIVE_TAGS are &[&str], not arrays with a length.
    (#16)
  • SitemapUrl::changefreq takes a ChangeFreq instead of text; priority is clamped to
    0.0..=1.0. (#20)
  • StaticSiteGenerator returns SsgError, not io::Error. It converts into
    io::Error, so ? in a function returning io::Result still works.
    (#19)
  • WASM: child, addHead and addBody take their element by value, which consumes
    the JavaScript handle; using it afterwards throws null pointer passed to rust.
    (#23)
  • The parallel feature implies ssg. (#22)

Security

Output now differs in the cases below, on purpose; each is also a row in the Output changes
table of MIGRATION.md.

  • Comments can no longer close early. Node::comment("x--->") used to leave a -->
    that ended the comment and let the rest through as markup. (#2)
  • Tag names are validated. Element::new("img src=x onerror=alert(1)") was written
    verbatim, also from JavaScript through new WElement(str). An element whose tag is not a
    letter followed by letters, digits, -, _, . or : is not rendered.
    (#3)
  • < and > in attribute values are escaped under raw-text ancestors (noscript,
    iframe, xmp, noembed, noframes, script, style, plaintext), where
    </noscript> inside an alt ended the parent. Elsewhere the byte-for-byte output is
    unchanged. (#5)
  • meta_name, meta_property, meta_charset and meta_http_equiv escape their
    values.
    (#4)
  • StaticSiteGenerator: refuses symlinks on the way, paths that name no file ("",
    ., a/) and Windows drive prefixes; writes through unique temporary files (two pages
    with the same stem used to share one); copy_asset no longer deletes before it copies;
    clean refuses ., the working directory and its ancestors, $HOME and top-level
    directories. (#6,
    #7,
    #8)
  • URL policy: also covers ping, manifest, longdesc and, per candidate, srcset;
    srcdoc is written empty unless trusted_url; on iframe, frame, embed and object
    a data: URL passes only if it is a raster image. is_blocked_in(tag, …) is the new
    tag-aware form. (#25)
  • XML: escape_xml drops the characters XML 1.0 cannot hold; a sitemap <loc> or feed
    <link> that is not an absolute http(s) URL is left out; isPermaLink="true" is written
    only for an http(s) guid. (#27)
  • RenderOptions::with_max_depth drops elements nested deeper than a limit, which is what
    bounds pretty output (quadratic in depth). (#28)
  • CI and release: every action pinned to a commit SHA, read-only default token,
    persist-credentials: false, job timeouts, and a release that refuses a tag that is not
    on main or has no green CI run. (#29)

Fixed

  • Document::render, accessibility::audit, Node::is_empty, Clone, PartialEq and
    Hash recursed once per level and aborted the process on a deep tree that the renderer
    handled. All are iterative now, tested at 100,000 levels.
    (#9,
    #10,
    #11) Debug is still recursive.
  • SECURITY.md and the WASM docs described a 256-level limit and a function name that did
    not exist. (#12)

Added

  • Markup, SsgError, ChangeFreq and ParseChangeFreqError.
  • seo::json_ld, seo::script_json and escape_json_script: JSON that is safe inside a
    <script>, where HTML escaping would corrupt it and no escaping would let </script>
    through. WASM jsonLd. (#26)
  • Element::from_static, RenderOptions::{indent, with_max_depth},
    core::tags::is_valid_tag_name, core::url_policy::{is_http_url, is_blocked_in},
    sitemap::{MAX_URLS, MAX_BYTES, SitemapGenerator::chunks}.
  • Trait impls: Display for Node, Element and Document ({:#} pretty-prints);
    Hash; Default for Document; FromIterator for Node; Extend for Element;
    From<Vec<Node>>, From<Option<T>> and From<char> for Node; Render for &T,
    Box<T> and Option<T>. (#17)
  • WASM: WDocument.addSeo, WDocument.renderWithOptions, and on WElement addClasses,
    rawChild, selfClosing, renderWithOptions and renderBytes.
    (#24)
  • .claude/skills/molt: a knowledge base for agents (security, Rust practice, performance,
    design patterns, governance, a decision log) whose lessons name the tests that guard them;
    scripts/check-knowledge-base.sh checks that those still exist.
  • tests/allocations.rs pins allocation counts and type sizes; the benchmarks run at
    opt-level = 3 and no longer time the Drop.

Changed

  • Tag names and attribute keys are Cow<'static, str> internally; div() makes no
    allocation. Element::new and Attribute::new still take impl Into<String>.
    (#15)

  • html! formats interpolated values straight into their escaped form: 40% faster to
    build, with the same tree.

  • Escapers copy the clean stretches between special characters in one step: prose-like text
    is about twice as fast, and text where every other character needs escaping about 2.8×
    slower (still ~400 MB/s).

  • Attribute::raw is documented as one of the three escape hatches, with the reason.

  • The published crate leaves out development tooling: rust-toolchain.toml (it made rustup
    install a wasm target and extra components for anyone building inside the unpacked tarball),
    AGENTS.md, CLAUDE.md, clippy.toml, rustfmt.toml, deny.toml and codecov.yml. The
    tests run from the extracted tarball: 480 pass.

  • core::url_policy::is_http_url no longer ignores leading whitespace. It is an allow list
    used to decide what a sitemap or feed may link to, and a reader that does not trim would
    read "\thttps://…" as a relative path.

  • CI builds the documentation the way docs.rs does (nightly, every feature, --cfg docsrs).

  • CI now tests the minimum supported Rust version for real. The 1.85 legs of the test
    matrix had been running on stable: the repository's rust-toolchain.toml overrides the
    toolchain the setup action installs. They now set RUSTUP_TOOLCHAIN and fail if rustc is
    not the version asked for. The claim held (all tests pass on 1.85.1), but nothing had proved it.

  • tests/invariants.rs: property tests that run the escapers, the URL policy, the tag and
    attribute writers, the XML generators and the static site generator on tens of thousands of
    hostile inputs per run, from a fixed seed, on every platform.

Not changed, deliberately

panic = "abort", the three HTML/XML escapers, escape_attribute leaving < and > alone
outside raw-text ancestors, and the golden fixtures. Four tests were added after the fact
because they were claimed but missing (#57).

Install

[dependencies]
molt-framework = "1.0.0"

The library is imported as molt: use molt::prelude::*;

What's Changed

  • Docs: README linka o crates.io, remove Brand e cita o port 3.0.1 by @micheltlutz in #43
  • Fix: comentário não fecha mais com ---> (S1) by @micheltlutz in #44
  • Fix: nome de tag inválido não é mais escrito no HTML (S2) by @micheltlutz in #45
  • Fix: < e > em atributos são escapados sob ancestrais raw-text (S4) by @micheltlutz in #46
  • Fix: valores dos helpers meta_* passam pelo escape de atributo (S3) by @micheltlutz in #47
  • Fix: SSG recusa symlink, caminhos sem arquivo e clean() do cwd (S5, S6, B1) by @micheltlutz in #48
  • Fix: Document, audit, Clone e PartialEq não recursam por nível (B2–B5) by @micheltlutz in #49
  • Change: superfície pública do 1.0 — non_exhaustive, tags como slice, Layout::wrap (A1, A4, A6, A10) by @micheltlutz in #50
  • Change: tag e chave de atributo como Cow<'static, str>; escape_* devolve Cow (A3, A9, P2) by @micheltlutz in #51
  • Change: Node opaco (Markup) e traits comuns (A2, A5) by @micheltlutz in #52
  • Change: SsgError tipado e ChangeFreq no sitemap (A7, A8) by @micheltlutz in #53
  • Change: WASM recebe handles por valor e ganha addSeo e opções (W1, W2) by @micheltlutz in #54
  • Test: benchmarks confiáveis e orçamentos de alocação (P0) by @micheltlutz in #55
  • Perf: escapers copiam trechos limpos com push_str (P4) by @micheltlutz in #56
  • Test: restaura os testes do S2 e S4 que nunca entraram by @micheltlutz in #57
  • Docs: base de conhecimento de boas práticas de Rust para agentes by @micheltlutz in #58
  • Perf: html! formata Display direto, sem to_string intermediário by @micheltlutz in #59
  • Perf: trusted_url sem cópia da chave; teto de tamanho dos tipos (P3, P8) by @micheltlutz in #60
  • Docs: README convida a contribuir e a apoiar pelo GitHub Sponsors by @micheltlutz in #62
  • Fix: indent só aceita espaço e tab; RenderOptions::with_max_depth (S10) by @micheltlutz in #64
  • Fix: XML sem caracteres ilegais, links http(s), isPermaLink verdadeiro (S9) by @micheltlutz in #65
  • Fix: política de URL cobre srcset, ping, srcdoc e data: em frames (S7) by @micheltlutz in #66
  • Add: seo::json_ld e script_json, JSON seguro dentro de <script> (S8) by @micheltlutz in #67
  • Fix: CI e release com SHAs fixados, permissões mínimas e gates (S11) by @micheltlutz in #68
  • Docs: base de conhecimento registra o lote D de segurança (L25–L30) by @micheltlutz in #69
  • Docs: CHANGELOG do 1.0, MIGRATION.md, GETTING_STARTED.md e skill molt-migrate (D2, D4) by @micheltlutz in #70
  • Docs: AGENTS.md ampliado, SECURITY.md com OWASP, docs/upstream-findings.md (D3) by @micheltlutz in #71
  • Docs: estabilidade do Render, aviso em Node::raw, ROADMAP.md (D4) by @micheltlutz in #72
  • Fix: guias de doctest não rodam em wasm32; verify.sh roda o wasm-pack test by @micheltlutz in #73
  • Docs: base de conhecimento registra a política de superar o Swift e L31-L32 by @micheltlutz in #74
  • Docs: remove a seção Parity with Winged-Swift do README by @micheltlutz in #75
  • Docs: remove as referências ao Winged-Swift (fase 1) e move o porte para docs/history by @micheltlutz in #81
  • Fix: teste de orçamento de alocações não é mais instável (mínimo de nove medições) by @micheltlutz in #84
  • Refactor: remove as referências ao Winged-Swift (fase 2) e o script de paridade by @micheltlutz in #85
  • Test: testes de propriedade, pacote enxuto e job do docs.rs (auditoria pré-1.0) by @micheltlutz in #87
  • Update: versão 1.0.0 by @micheltlutz in #89
  • Release 1.0.0: develop em main by @micheltlutz in #90

New Contributors

Full Changelog: v0.1.0...v1.0.0