Permalink
Browse files

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.
  • Loading branch information...
reillysiemens committed Mar 26, 2017
1 parent 817fe0f commit 7c1cecb2112e087e2ffb45937bea29ebf81df01e
Showing with 1 addition and 1 deletion.
  1. +1 −1 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();
}

0 comments on commit 7c1cecb

Please sign in to comment.