Content: Tuned HTML purifier for our use

Tested it with a range of supported, including uncommon, content types
and added support, or changed config, where needed.
Been through docs for all HTMLPurifier options to assess what's
relevant.
This commit is contained in:
Dan Brown
2026-02-15 16:17:03 +00:00
parent 10ebe53bd9
commit 0f040fe8b1
3 changed files with 104 additions and 6 deletions

View File

@@ -321,12 +321,13 @@ class PageContent
$cacheKey = $this->getContentCacheKey($doc->getBodyInnerHtml());
$cached = cache()->get($cacheKey, null);
if ($cached !== null) {
return $cached;
// return $cached;
}
$filterConfig = HtmlContentFilterConfig::fromConfigString(config('app.content_filtering'));
$filter = new HtmlContentFilter($filterConfig);
$filtered = $filter->filterDocument($doc);
// $filtered = $doc->getBodyInnerHtml();
$cacheTime = 86400 * 7; // 1 week
cache()->put($cacheKey, $filtered, $cacheTime);