Open
Description
Setting HTML.XHTML to true doesn't affect tags, however, it is written in documentation that
[...] in HTML5 it's used for enabling support for namespaced attributes and XML self-closing tags.
I tried to pass this option in Custom HTMLPurifier Class:
namespace App\HtmlPurifier;
final class CustomPurifier extends \HTMLPurifier
{
public function __construct($var)
{
$config = \HTMLPurifier_HTML5Config::createDefault();
$config->set('HTML.XHTML', true);
parent::__construct($config);
}
}
Service :
services:
# HTMLPurifier
App\HtmlPurifier\CustomPurifier:
tags:
- name: exercise.html_purifier
profile: default
exercise_html_purifier.default: '@App\HtmlPurifier\CustomPurifier'
In Controller, I use the right HTMLPurifier, it's ok. But purify() method do not convert html tags to self-closing tags.
$html = "<img src='test.png'/><hr/><br/>";
$purifier->purify($html); // "<img src="test.png" alt="test.png"><hr><br>"
I was expecting that it will return <img src="test.png" alt="test.png"/><hr/><br/>
Maybe I did not understand what HTML.XHTML is supposed to do