Skip to content

Commit

Permalink
avoid crash on inline HTML inside blockquote
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Sep 23, 2024
1 parent 7772303 commit ebc4964
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions v2/fuzz/fuzz_targets/parse_markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fuzz_target!(|data: &[u8]| {
else {
return;
};
dbg!(&source);
let target = MarkdownContent::new(source, None);
let parser = MarkdownParser::new(&target, offset, ());
let mut buf = Vec::new();
Expand Down
9 changes: 7 additions & 2 deletions v2/src/markdown/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,12 @@ impl<'input, W: Write, V: TextVisitor, T: TextTokenizer> RenderTreeEncoder<'inpu
self.text(&text, inner_range)?;
self.tag_end()?;
}
Event::Html(_) => unreachable!(), // This event is handled in `Tag::HtmlBlock` event using `HtmlBlockReader`
Event::InlineHtml(html) => {
// Inline HTML inside blockquote is emitted as Event::Html event wrongly. Uncomment the below line when
// the following issue is fixed and the fix is released.
// https://github.com/pulldown-cmark/pulldown-cmark/issues/960
//
// Event::Html(_) => unreachable!(), // This event is handled in `Tag::HtmlBlock` event using `HtmlBlockReader`
Event::Html(html) | Event::InlineHtml(html) => {
self.tag("html")?;
self.out.write_all(br#","raw":""#)?;

Expand Down Expand Up @@ -1053,6 +1057,7 @@ mod tests {
snapshot_test!(escaped_chars_in_text);
snapshot_test!(alert);
snapshot_test!(url_inside_link);
snapshot_test!(inline_html_inside_blockquote);

// Offset
snapshot_test!(offset_block, Some(30));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions v2/src/markdown/testdata/inline_html_inside_blockquote.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebc4964

Please sign in to comment.