From c4a3acaf70d51e3f66633b4a956eb8d173ca4177 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Wed, 1 Feb 2023 18:03:36 +0100 Subject: [PATCH] block: avoid panic on too short table line --- src/block.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/block.rs b/src/block.rs index 4b89599..54c435d 100644 --- a/src/block.rs +++ b/src/block.rs @@ -604,7 +604,8 @@ impl IdentifiedBlock { .then(|| (Kind::Atom(Attributes), Span::by_len(indent, l))), '|' => { // FIXME: last byte may be pipe but end of prefixed unicode char - (line.as_bytes()[lt - 1] == b'|' && line.as_bytes()[lt - 2] != b'\\') + ((lt >= 2 && line.as_bytes()[lt - 1] == b'|') + && ((lt >= 3) && line.as_bytes()[lt - 2] != b'\\')) .then(|| (Kind::Table { caption: false }, Span::empty_at(indent))) } '[' => chars.as_str().find("]:").map(|l| {