Skip to content

Commit

Permalink
feat(HTMLPurifer): first step try to allow iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
J9rem committed Sep 15, 2023
1 parent 2b963e9 commit 616b25e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions includes/services/HtmlPurifierService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ public function cleanHTML(string $dirty_html): string
'_top',
]);

// allow iframe
$config->set('HTML.SafeIframe', true);
$config->set('HTML.SafeIframeRegexp', '%^https?://.*%');

// set the cache folder
// doc : http://htmlpurifier.org/live/configdoc/plain.html#Cache.SerializerPath
if (!is_dir(self::HTMLPURIFIER_CACHE_FOLDER)) {
mkdir(self::HTMLPURIFIER_CACHE_FOLDER, 0777, true);
}
$config->set('Cache.SerializerPath', realpath(self::HTMLPURIFIER_CACHE_FOLDER));

$def = $config->getHTMLDefinition(true);
$def->addAttribute('iframe', 'allowfullscreen', 'Bool');

$this->purifier = new HTMLPurifier($config);
}

Expand Down

0 comments on commit 616b25e

Please sign in to comment.