Purifier icon indicating copy to clipboard operation
Purifier copied to clipboard

Attr.EnableID doesn't work in default config

Open rawilk opened this issue 7 years ago • 2 comments

In my default purifier settings I have this:

'settings' => [
     'default' => [
            'HTML.Doctype'             => 'XHTML 1.0 Transitional',
            'HTML.Allowed'             => 'div,b,strong,i,em,u,a[href|title|target|rel],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
            'CSS.AllowedProperties'    => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
            'AutoFormat.AutoParagraph' => false,
            'AutoFormat.RemoveEmpty'   => false,
            'URI.AllowedSchemes'       => ['http' => true, 'https' => true, 'mailto' => true, 'data' => true],
            'Attr.EnableID'            => true,
            'Attr.AllowedFrameTargets' => '_blank',
            'Attr.AllowedRel'          => 'nofollow',
        ],

        ...
]

Even with that in there, I am still not able to use the id attribute on elements. I did find that if I pass this option in as the second parameter to clean, it does work. Why would it work then, and not when it's in the config file?

rawilk avatar Oct 21 '18 19:10 rawilk

@rawilk yes I am getting this too, with the latest version of everything, including Laravel 6.3, downloaded and tested just today.

bhuvidya avatar Oct 17 '19 05:10 bhuvidya

Thought I'd chime in to share something I had issues with today.

I wanted to enable anchors (they just add and id) on TinyMCE editor but couldn't make it work thinking that 'Attr.EnableID' => true, was the issue. Turns out that anchors add a "link" with the id to it, like so : <h1>Getting started !<a id="part2"></a></h1>

So allowing the id attribute for the a tags is necessary. 'HTML.Allowed' => 'div,p,strong,i,em,u,a[href|title|id]',

I also recommend reading this : http://htmlpurifier.org/docs/enduser-id.html

morencys avatar Oct 29 '20 03:10 morencys