diff --git a/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php b/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php index 67bb0b3307f..b2d9e70e77f 100644 --- a/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php +++ b/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php @@ -192,6 +192,41 @@ public function testHeadingsWithSpecialCharacters() HTML, $html); } + public function testHeadingsAllowMarkdownStyling() + { + $markdown = <<<'MARKDOWN' + ## Heading with **Markdown** styling + MARKDOWN; + + $html = (new MarkdownService($markdown, MarkdownPage::class))->parse(); + + $this->assertStringContainsString('Heading with Markdown styling', $html); + + $this->assertSame(<<<'HTML' +

Heading with Markdown styling

+ + HTML, $html); + } + + public function testHeadingsAllowBasicHtmlButEscapesDangerousInput() + { + $markdown = <<<'MARKDOWN' + ## Heading with HTML + ### Heading with + MARKDOWN; + + $html = (new MarkdownService($markdown, MarkdownPage::class))->parse(); + + $this->assertStringContainsString('Heading with HTML', $html); + $this->assertStringContainsString("Heading with <script>alert('XSS')</script>", $html); + + $this->assertSame(<<<'HTML' +

Heading with HTML

+

Heading with <script>alert('XSS')</script>

+ + HTML, $html); + } + public function testCustomPageClassConfiguration() { config(['markdown.permalinks.pages' => [MarkdownPage::class]]);