From f809481ab72d0a4a0c9fb6ed5bb4bac1f78f944e Mon Sep 17 00:00:00 2001 From: xxchan Date: Mon, 17 Jul 2023 12:48:05 +0200 Subject: [PATCH] fix: reject leading `.`, `)` without prefix as item marker fix #5835 --- src/comment.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/comment.rs b/src/comment.rs index 85918ecc116..b0ef924646d 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -484,7 +484,9 @@ impl ItemizedBlock { // allowed. for suffix in [". ", ") "] { if let Some((prefix, _)) = trimmed.split_once(suffix) { - if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) { + if (1..=2).contains(&prefix.len()) + && prefix.chars().all(|c| char::is_ascii_digit(&c)) + { return Some(prefix.len() + suffix.len()); } } @@ -2142,6 +2144,9 @@ fn main() { // https://spec.commonmark.org/0.30 says: "A start number may not be negative": "-1. Not a list item.", "-1 Not a list item.", + // Marker without prefix are not recognized as item markers: + ". Not a list item.", + ") Not a list item.", ]; for line in test_inputs.iter() { let maybe_block = ItemizedBlock::new(line);