Skip to content

Commit

Permalink
Fix bug in footnote fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 30, 2023
1 parent b0526c6 commit 56b45e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ pub fn normalize(events: Vec<Event<'_>>) -> Vec<Event<'_>> {
let mut footnotes: HashMap<String, Vec<Event<'_>>> = HashMap::new();
let mut in_footnote: Vec<usize> = Vec::new();
let mut normalized = Vec::with_capacity(events.len());
for (i, event) in events.into_iter().enumerate() {
for event in events.into_iter() {
match (normalized.last_mut(), &event) {
// Join adjacent text and HTML events.
(Some(Event::Text(prev)), Event::Text(next)) => *prev = format!("{prev}{next}").into(),
Expand Down Expand Up @@ -787,7 +787,7 @@ pub fn normalize(events: Vec<Event<'_>>) -> Vec<Event<'_>> {
}

(_, Event::Start(Tag::FootnoteDefinition(..))) => {
in_footnote.push(i);
in_footnote.push(normalized.len());
normalized.push(event);
}

Expand All @@ -797,7 +797,7 @@ pub fn normalize(events: Vec<Event<'_>>) -> Vec<Event<'_>> {
let footnote = normalized.split_off(j);
let name = match &footnote[0] {
Event::Start(Tag::FootnoteDefinition(name)) => name.clone(),
_ => panic!("this should not be possible"),
_ => panic!("this should not be possible {footnote:?}", footnote = footnote),
};
footnotes.insert(name.to_string(), footnote);
}
Expand Down

0 comments on commit 56b45e0

Please sign in to comment.