Repository navigation
Fix a panic on email addresses in image titles with GFM - #263
Open
ChristianMurphy wants to merge 1 commit into
Open
ChristianMurphy wants to merge 1 commit into
ChristianMurphy wants to merge 1 commit into
Conversation
Problem: the literal autolink resolver rewrote `Data` inside images, including linked title chunks, which are string content. In a title that spans lines, the rewrite dropped the links, and `divide_events` panicked. Changes: - Skip `Data` that carries a link. - Tests for a title that spans lines and one on a single line.
Murderlon
approved these changes
Oct 17, 2026
Murderlon
left a comment
Collaborator
There was a problem hiding this comment.
I authorized Codex to review this PR on my behalf.
No findings.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With GFM, an email address in an image title that spans lines panics in 1.0.0:
CommonMark renders
<p><img src="b" alt="a" title="c@d.com\ne" /></p>, and GFM doesn't autolink in titles.The GFM autolink literal resolver scans
Dataoutside links for email addresses and rewrites it into autolinks. It skippedDatainside aLink, but not inside anImage. So it also rewrote image title chunks, which are string content and point to the next chunk through theirlinkfield. The rewrite dropped that field, anddivide_eventspanicked. This skipsDatathat has alink, the same check #207 adds toresolve_whitespace.Output changes
Single-line image titles change too. 1.0.0 rewrote them, which could escape a character reference twice:
gave the titlec@d.com &amp; e. It is nowc@d.com & e, as micromark-extension-gfm gives it.Performance
Callgrind, with one codegen unit, against 1.0.0 built the same way, across 7 option sets. On small documents, instructions change by −0.6% to +0.2%, within the noise of this method.
Tests
subtokenize.rs:149panic (GH-79) #207 alone, 1,007 of them panic, all with@in a title. With both, none do.As of 2026-09-29, CI on
mainfails for two reasons unrelated to this change. One is a new clippy lint on Rust 1.98, and the other is the swc/serde build break. #230 fixes both.Claude, an AI assistant, helped me build this, and I reviewed it.