diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index 746a2d04..793451ab 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -374,7 +374,7 @@ protected function hashHTMLBlocks($text) { \2\s*> # closing nested tag ) | - <(?!/\2\s*> # other tags with a different name + <(?!/?\2[\s/>])(?!/\2\s*> # other tags (not an open/close of \2) ) )*', $nested_tags_level); diff --git a/test/unit/MarkdownHtmlBlockTest.php b/test/unit/MarkdownHtmlBlockTest.php new file mode 100644 index 00000000..2f27d853 --- /dev/null +++ b/test/unit/MarkdownHtmlBlockTest.php @@ -0,0 +1,118 @@ + array(str_repeat("
and not escaped. + $this->assertStringContainsString("
', $result); + $this->assertStringNotContainsString('<', $result); + } + + public function tooDeeplyNested(): array + { + $cases = array(); + foreach (array(5, 6, 8) as $depth) { + $cases["depth $depth"] = array( + str_repeat("