Fix underflow in table header count calc
@@ -1307,11 +1307,11 @@ fn count_header_cols(bytes: &[u8], mut pipes: usize, mut start: usize, last_pipe
// was last pipe followed by whitespace? if so, sub one
if scan_blank_line(&bytes[(last_pipe_ix + 1)..]).is_some() {
- pipes -= 1;
- }
-
+ pipes
+ } else {
pipes + 1
}
+}
impl<'a> Tree<Item> {
fn append_text(&mut self, start: usize, end: usize) {
@@ -2519,6 +2519,13 @@ mod test {
parser_with_extensions(":\r\t> |\r:\r\t> |\r").count();
}
+ #[test]
+ fn issue_319() {
+ // dont crash
+ parser_with_extensions("|\r-]([^|\r-]([^").count();
+ parser_with_extensions("|\r\r=][^|\r\r=][^car").count();
+ }
+
#[test]
fn issue_303() {
// dont crash
