From 7c1cecb2112e087e2ffb45937bea29ebf81df01e Mon Sep 17 00:00:00 2001 From: Reilly Tucker Siemens Date: Sun, 26 Mar 2017 02:52:06 -0700 Subject: [PATCH] Use lazy front-matter regex Using a greedy regex could lead to unintended consequences, like the inability to syntax highlight a unified diff. This resolves issues like that by using .*? instead of .* so that the closing +++ is matched as soon as possible. --- src/front_matter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/front_matter.rs b/src/front_matter.rs index c9d77321..84b6bef7 100644 --- a/src/front_matter.rs +++ b/src/front_matter.rs @@ -11,7 +11,7 @@ use errors::{Result, ResultExt}; lazy_static! { - static ref PAGE_RE: Regex = Regex::new(r"^\n?\+\+\+\n((?s).*(?-s))\+\+\+\n?((?s).*(?-s))$").unwrap(); + static ref PAGE_RE: Regex = Regex::new(r"^\n?\+\+\+\n((?s).*?(?-s))\+\+\+\n?((?s).*(?-s))$").unwrap(); }