aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/partial_mdx_jsx.rs20
-rw-r--r--tests/fuzz.rs12
2 files changed, 23 insertions, 9 deletions
diff --git a/src/construct/partial_mdx_jsx.rs b/src/construct/partial_mdx_jsx.rs
index fc03f82..2031a5a 100644
--- a/src/construct/partial_mdx_jsx.rs
+++ b/src/construct/partial_mdx_jsx.rs
@@ -1070,17 +1070,19 @@ pub fn es_whitespace_inside(tokenizer: &mut Tokenizer) -> State {
tokenizer.consume();
State::Next(StateName::MdxJsxEsWhitespaceInside)
}
- _ => {
+ Some(_)
if kind_after_index(tokenizer.parse_state.bytes, tokenizer.point.index)
- == CharacterKind::Whitespace
- {
- tokenizer.consume();
- State::Next(StateName::MdxJsxEsWhitespaceInside)
- } else {
- tokenizer.exit(Name::MdxJsxEsWhitespace);
- State::Ok
- }
+ == CharacterKind::Whitespace =>
+ {
+ tokenizer.consume();
+ State::Next(StateName::MdxJsxEsWhitespaceInside)
+ }
+ Some(_) => {
+ tokenizer.exit(Name::MdxJsxEsWhitespace);
+ State::Ok
}
+ // Handle EOF.
+ None => State::Nok,
}
}
diff --git a/tests/fuzz.rs b/tests/fuzz.rs
index 297e6a9..4778cbb 100644
--- a/tests/fuzz.rs
+++ b/tests/fuzz.rs
@@ -117,5 +117,17 @@ fn fuzz() -> Result<(), String> {
"11: gfm task list items followed by eols (GH-24)"
);
+ assert_eq!(
+ markdown::to_html_with_options(
+ "<",
+ &markdown::Options {
+ parse: markdown::ParseOptions::mdx(),
+ ..Default::default()
+ }
+ ),
+ Ok("<p>&lt;</p>".to_string()),
+ "12: mdx: handle invalid mdx without panic (GH-26)"
+ );
+
Ok(())
}