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.
This commit is contained in:
Reilly Tucker Siemens 2017-03-26 02:52:06 -07:00
parent 817fe0f027
commit 7c1cecb211

View file

@ -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();
}