Skip to content

fix(markdown): the tag end in the link pre-pass comes from a separate hand-written scan #233

Closed as not planned

Description

@tobocop2

The markdown pre-pass finds where each start tag ends with a hand-written scan (start_tag_end in crates/crawlberg/src/html/link_targets.rs), while the rest of the pass now takes tags from the html5ever tree builder (#232). Nothing checks that the hand-written scan agrees with html5ever about where a tag ends, for example with quotes inside unquoted values, / before >, or attributes without values.

Fix

Take the tag end offset from the html5ever scan the pass already runs, or add a differential test of the scan against html5ever over a corpus of start tags.

Measured on #123 (review of c58c8bd05)

  • The hand-written tag-end scan ends 5,800 of 283,305 corpus start tags where html5ever does not. <a href=b ="x>z</a><a href="y"> gives the first link the second link's address, and <img src="data:..." ="x>"> leaks the payload into the markdown.
  • Where tl and html5ever read a different attribute value (<img == src="data:...">, <img alt=<TAB>"x src=data:...">), the payload that tl sees reaches the markdown.
  • The later-copy scan in link_targets.rs can panic if the value span ends before it starts; no fuzz input reached it, and a checked slice removes it.
    Taking tag ends and values from html5ever (on top of fix(html): use one definition of raw text for link extraction and markdown #232) removes all three.

Activity

  1. self-assigned this
    on Sep 26, 2026
  2. added
    correctness
    P2
    bug
    on Sep 27, 2026
  3. added theissue type on Sep 27, 2026
  4. Goldziher commented on Sep 27, 2026

    @Goldziher
    Member

    The hand-written tag-end scan exists only to serve the pre-pass, and the pre-pass's URL-joining half is now redundant: ConversionOptions::base_url (html-to-markdown-rs 3.15, plus blockquote cite in 3.15.1) resolves the same target set TARGETS mirrors — a href, img src and its lazy fallbacks, srcset, graphic, iframe/audio/video/source src — inside the converter's own html5ever parse.

    Bump Cargo.toml:84 and adopt it (#190) rather than building a differential test for a second reading of the page. The data: payload leak in the measured examples is the one part that survives, and it is itself an upstream ask (#97).

  5. added
    operator
    on Sep 27, 2026
  6. tobocop2 commented on Oct 1, 2026

    @tobocop2
    MemberAuthor

    Closing as not real. start_tag_end came from closed PRs #123 and #232, and git grep start_tag_end at b632f34 finds nothing on main.

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

Metadata

Metadata

Assignees

Labels

P2bugcorrectnessoperator

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions