getzola · GitHub

Commit 7c1cecb

committed

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.

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src

Lines changed: 1 addition & 1 deletion

Original file line numberDiff line numberDiff line change

@@ -11,7 +11,7 @@ use errors::{Result, ResultExt};

1111
1212
1313

lazy_static! {

14-

static ref PAGE_RE: Regex = Regex::new(r"^\n?\+\+\+\n((?s).*(?-s))\+\+\+\n?((?s).*(?-s))$").unwrap();

14+

static ref PAGE_RE: Regex = Regex::new(r"^\n?\+\+\+\n((?s).*?(?-s))\+\+\+\n?((?s).*(?-s))$").unwrap();

1515

}

1616
1717

Read the original on github.com ↗