-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stripping out HTML attributes regardless of settings #217
Comments
Hi, thanks for reaching out! Custom attributes and classes are stripped out (by default) by CKEditor itself, but you can change that via configuration. In a nutshell, you choose which “buttons” each CKEditor configuration should support, and you can further tweak their behaviour via “Config Options”. Within the “Config Options”, you can provide a configuration that’s described at https://ckeditor.com/docs/ckeditor5. In terms of When it comes to classes, CKEditor will allow you to specify them via the Styles feature. Here are some related issues regarding styles and classes: #135, #105, #91. Finally, if you’re using the Source editing feature, it has a I hope this clears things up! I'll close this now, but feel free to reach out if anything's unclear. |
@i-just, There seems to be some confusion about the "Purify HTML" feature. When we disable it, are we supposed to be able to include any HTML code in the source? We've encountered a situation where we turned it off, but the HTML was still being sanitized. Can you clarify how this feature works? |
@a-am, not quite. If you disable “Purify HTML”, you’ll be allowed to include any HTML code that CKEditor is configured to allow you to. I guess the easiest way to see what’s going on would be to first disable the purifier in your dev environment, configure CKEditor to allow all the tags/classes/attributes you need, test that they’re all retained between saved, and then enable the purifier and see if any adjustments to the purifier config are needed. |
Thanks @i-just ! For one of the sites I'm adding this to, I'm the developer and the only CP editor, and don't need any handrails. What's the easiest way to disable this completely, so I can click Source and add whatever I want? The docs say to install
|
I found my problem @i-just. The docs say to add:
But
|
Description
HTML attributes added to the source HTML of a CKEditor field are being stripped out, regardless of config settings in the CP or in the HTML Purifier config file. Attributes such as
target="_blank"
for external links is critical functionality, yet still being removed. Class names and other attributes are removed from all elements as well. Unchecking"Purify HTML"
in the field's advanced settings has no effect on this. I also tried adding every relevant setting I could find in the links the plugin provides atckeditor.com
andhtmlpurifier.org
, and they had no effect, even after clearing caches. For example, I tried re-enabling"Purify HTML"
and adding settings (i.e.HTML.AllowedAttributes
) to the field's selected HTMLPurifier's json file, and it made no difference. Neither did adding settings to the CKEditor Configs in the CP.The docs at these links aren't specific to Craft, so its unclear what the preferred method is to handle this, or if all of these settings are even implemented. And I found this question asked multiple times in the Discord group with no responses, leading me to believe that there aren't many users clear on how to handle this.
I believe addressing this should be high priority since it blocks critical functionality like external linking, and because some site editors that understand code, need the ability to add HTML that's more complex than what the buttons and custom styles will easily allow.
Steps to reproduce
Additional info
The text was updated successfully, but these errors were encountered: