From 2574208a529ec9fe2f1af0ab2596369e3d449453 Mon Sep 17 00:00:00 2001 From: Thomas Leitner Date: Wed, 1 Jul 2015 09:28:23 +0200 Subject: [PATCH] Fixed regexp backtracking problem in footnote definitions and codeblocks Fixes #256 --- lib/kramdown/parser/kramdown/blank_line.rb | 2 +- .../span/04_footnote/regexp_problem.html | 14 +++++ .../span/04_footnote/regexp_problem.text | 52 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 test/testcases/span/04_footnote/regexp_problem.html create mode 100644 test/testcases/span/04_footnote/regexp_problem.text diff --git a/lib/kramdown/parser/kramdown/blank_line.rb b/lib/kramdown/parser/kramdown/blank_line.rb index 538d1169..148ce523 100644 --- a/lib/kramdown/parser/kramdown/blank_line.rb +++ b/lib/kramdown/parser/kramdown/blank_line.rb @@ -11,7 +11,7 @@ module Kramdown module Parser class Kramdown - BLANK_LINE = /(?:^\s*\n)+/ + BLANK_LINE = /(?>^\s*\n)+/ # Parse the blank line at the current postition. def parse_blank_line diff --git a/test/testcases/span/04_footnote/regexp_problem.html b/test/testcases/span/04_footnote/regexp_problem.html new file mode 100644 index 00000000..8ea102b7 --- /dev/null +++ b/test/testcases/span/04_footnote/regexp_problem.html @@ -0,0 +1,14 @@ +

Something

+

something1.

+ +

Footnotes

+ +

Test

+
+
    +
  1. + +

    A note

    +
  2. +
+
diff --git a/test/testcases/span/04_footnote/regexp_problem.text b/test/testcases/span/04_footnote/regexp_problem.text new file mode 100644 index 00000000..6a60c612 --- /dev/null +++ b/test/testcases/span/04_footnote/regexp_problem.text @@ -0,0 +1,52 @@ +# Something +something[^note1]. + +# Footnotes +[^note1]: + A note + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Test