. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Services; use HTMLPurifier; use HTMLPurifier_Config; /** * Filter/sanitize HTML */ class HtmlService { /** * Take some dirty HTML (as provided by the user), and clean it before * we save/display it. * * @param string $html * * @return string */ public function sanitize(string $html): string { $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); return $purifier->purify($html); } }