Closed sdespont closed 4 years ago
It may be more useful to try to add video
element support to the main HTMLPurifier library.
Hello,
updated code working with last version :
Source : https://github.com/kennberg/php-htmlpurfier-html5/blob/master/htmlpurifier_html5.php
/**
* Constructor.
*
* @param \HTMLPurifier $purifier
*/
public function __construct($purifier)
{
//Find full HTML5 config : https://github.com/kennberg/php-htmlpurfier-html5
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
// Set some HTML5 properties
$config->set('HTML.DefinitionID', 'html5-definitions'); // unqiue id
$config->set('HTML.DefinitionRev', 1);
if ($def = $config->maybeGetRawHTMLDefinition()) {
// http://developers.whatwg.org/the-video-element.html#the-video-element
$def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array(
'src' => 'URI',
'type' => 'Text',
'width' => 'Length',
'height' => 'Length',
'poster' => 'URI',
'preload' => 'Enum#auto,metadata,none',
'controls' => 'Bool',
));
$def->addElement('source', 'Block', 'Flow', 'Common', array(
'src' => 'URI',
'type' => 'Text',
));
}
$this->purifier = new \HTMLPurifier($config);
}
Closing this old issue because the problem of the OP has been resolved and we already have #26 to track the featuring of such configuration with YAML too. Thanks!
I adapted the code some times ago to accept the "< video >" tags, but it is not working anymore since versions 0.2.X and I really don't know why. The "< video >" tag is still present after purrifying, but the "src" element is removed.
Any hints to figure this out?