Skip to content

fix(browser): the HTML serializer's raw-text elements differ from the HTML rule #288

Closed

Description

@tobocop2

The browser crate's HTML serializer (crates/crawlberg-browser/src/dom/serialize.rs:138) uses a raw-text element set that differs from the HTML serialization rule: xmp, iframe, noembed, noframes and plaintext are missing (their text should be written unescaped), and title and textarea are in the set although their text should be escaped. A rendered page's serialized HTML can therefore differ from what a browser would serialize. Found while reviewing #232; not yet reproduced with a page.

Fix

Match the serializer's raw-text set to the HTML fragment serialization algorithm and add a round-trip test per element.

Activity

  1. added
    correctness
    P2
    bug
    on Sep 27, 2026
  2. added theissue type on Sep 27, 2026
  3. added
    P3
    and removed
    P2
    on Sep 27, 2026
  4. tobocop2 commented on Oct 1, 2026

    @tobocop2
    MemberAuthor

    #511 shows the effect of the title and textarea half: the serializer writes text such as </title><a href="/evil"> unescaped, so the HTML that crawlberg extracts from gains an extra link after the reparse. The native backend reaches this on every render.

  5. Goldziher commented on Oct 4, 2026

    @Goldziher
    Member

    Implemented, reviewed, and pushed to main in the dependency-upgrade/fix series ending at 56d093a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3bugcorrectness

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions