Skip to content

Commit

Permalink
Fix panic while getting byte outside char boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarton committed Aug 3, 2017
1 parent 5277ba2 commit a2b8d17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ impl<'a> RawParser<'a> {
if self.off + 1 + beg_tag.len() < self.text.len() &&
self.text[self.off + 1..].starts_with(&beg_tag[..]) {
let pos = self.off + beg_tag.len() + 1;
let s = &self.text[pos..pos + 1];
if s == " " || s == "\n" || s == ">" {
let s = self.text.as_bytes()[pos];
if s == b' ' || s == b'\n' || s == b'>' {
return Some(end_tag);
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ fn test_infinite_loop() {
let parser = Parser::new(&markdown);
for _ in parser { }
}

#[test]
fn test_html_tag() {
let markdown = "<script\u{feff}";
use pulldown_cmark::Parser;

let parser = Parser::new(&markdown);
for _ in parser { }
}

0 comments on commit a2b8d17

Please sign in to comment.