heidkaemper / craft-redactor-anchors

Support for anchors in Craft CMS Redactor
https://plugins.craftcms.com/redactor-anchors
MIT License
10 stars 4 forks source link

HTMLPurifier Attr.EnableID option required to save page anchors #2

Closed danwill closed 3 years ago

danwill commented 4 years ago

Page anchors added with this plugin will be removed on save by the default HTMLPurifier settings. You may want to document that the the Attr.EnableID option should be set to true in order to keep page anchors.

It's worth mentioning that IDs are disallowed by default because:

without proper configuration, user input can easily break the validation of a webpage by specifying an ID that is already on the surrounding HTML.

More information here: http://htmlpurifier.org/live/configdoc/plain.html#Attr.EnableID

HTMLPurifier settings can be modified by creating a .json file in config/htmlpurifier/ (e.g. config/htmlpurifier/Standard.json). Then, this config can be selected when setting up a Redactor field within the field's Advanced options.

ccchapman commented 3 years ago

Craft's starter project now includes config/htmlpurifier/Default.json out of the box with Attr.EnableID set to true.

https://github.com/craftcms/craft/commit/c0f495ed7b2e9ded2889c3ea27328f616f0b2c2f