Purifier
Purifier copied to clipboard
Support addAttribute via config file
With the vanilla HTML Purifier, if we wanted to add support for the allowfullscreen attribute on iframes we could add the attribute to the config like so:
$def = $config->getHTMLDefinition(true);
//add attribute allowfullscreen to iframe element
//allow values of true, false, and empty
$def->addAttribute('iframe', 'allowfullscreen', 'Enum#true,false,');
http://htmlpurifier.org/docs/enduser-customize.html#addAttribute
Could this be added and supported via a config file?
In case you still want that feature, I just added it in my fork.
@codel Thanks for adding this feature. But I cant find any documentation to addElement.
I want to add these tags u
, strike
, pre
, code
and blockquote
. How can i do this, an example will be very helpful.
here is my config files settings.default
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],strike,u,ul,ol,code,pre, blockquote,li,p,br,span[style],img[width|height|alt|src]',
'CSS.AllowedProperties' => 'text-align',
'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
],
I need a target="_blank" in my urls. I cannot add it to the HTML.Allowed. I also need support for this.
@JackPoint
'default' => [
'HTML.Doctype' => 'HTML 4.01 Transitional',
'Attr.AllowedFrameTargets' => '_blank',
'Attr.AllowedRel' => 'nofollow',
'HTML.Allowed' => 'h2,strike,blockquote,u,div,b,strong,i,em,a[href|title|target|rel],ul,ol,li,p,br,span,img[width|height|alt|src]',
'CSS.AllowedProperties' => 'font,font-weight,font-style,text-decoration,padding-left,text-align',
'AutoFormat.AutoParagraph' => false,
'AutoFormat.RemoveEmpty' => true,
],
@itbdw great that works for me! Thanks.
Is it possible to do this now? I need to restrict classes used in tags.
@itbdw you saved my day!!!