Skip to content

Commit

Permalink
fix: corrected HTML sanitizer configuration (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jun 11, 2023
1 parent be1a20d commit 5495a55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Helper/FaqHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ public function createFaqUrl(FaqEntity $faqEntity, int $categoryId): string
public function cleanUpContent(string $content): string
{
$htmlSanitizer = new HtmlSanitizer(
(new HtmlSanitizerConfig())->allowSafeElements()
(new HtmlSanitizerConfig())
->allowSafeElements()
->allowStaticElements()
->allowRelativeLinks()
->allowRelativeMedias()
);

return $htmlSanitizer->sanitize($content);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpMyFAQ/Helper/FaqHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testCreateFaqUrl(): void
public function testCleanUpContent(): void
{
$content = '<p>Some text <script>alert("Hello, world!");</script><img src=foo onerror=alert(document.cookie)></p>';
$expectedOutput = '<p>Some text <img /></p>';
$expectedOutput = '<p>Some text <img src="foo" /></p>';

$actualOutput = $this->faqHelper->cleanUpContent($content);

Expand Down

0 comments on commit 5495a55

Please sign in to comment.