Jump to content

html purifier configuration (or html5 version?)


Recommended Posts

I'm still learning and reading, and I haven't yet figured out how to really configure the html purifier.

For now its bothering me that media elements (such as video) are plain stripped out (added with TinyMCE), so in order to be able using these it seems I need to whitelist those manually.

After some reading I found this github topic, but I'm not sure yet how to really use that information, so perhaps someone can enlighten me which steps I have to take and someone can give me a more detailed instruction how and where to really add these hooks, and/or if and how it is maybe possible to switch to the in the topic mentioned html5 version of it?

Link to comment
Share on other sites

This would be the included version 6.1.5

And yes, I've been using CKEditor so far as well, but regarding the age of the included version and the annoying handling of extensions/plugins I thought to give TinyMCE a try in my new project and I am quite satisfied so far.

Well, there is no such setting (or I must have missed it), there are some settings which make sense like invalid styles and tools to be removed from the toolbar to make it usable in PW without the user having a chance to confuse things, but nothing like whitelisting specific html. Also the pastefilter whitelist, but I want to make use of the media tool (button) from TinyMCE, which just inserts the corresponding html5 code.

Besides, I am pretty sure it is in the purifier because it seems to be no problem when disabling it- which I don't want to for obvious reasons.

Link to comment
Share on other sites

You have to look for it in the module settings, not in the field settings
Pastefilter whitelist is the section. Paste in this:

p, strong, em, hr, br, u, s, h1, h2, h3, h4, h5, h6, ul, ol, li, blockquote, cite, a[href|id], a[target=_blank], img[src|alt], img[class=align_left|align_right|align_center], table[border], thead, tbody, tfoot, tr[rowspan], td[colspan], th[colspan], colgroup, col, sup, sub, figure, figcaption, code, pre, b=strong, i=em, video

I just added video at the end of the default tags. I guess that the purifier will ignore this tags.

Link to comment
Share on other sites

Thanks, and yes, I was in the module settings and I've also seen the pastefilter.

Nevertheless I tried that idea, but as I was afraid this seems to have no effect at all.

Checking again what is written in the template regarding the pastefilter:


Reduces most pasted content to its basic semantic HTML to avoid messy tags and attributes from ending up in the editor due to a paste operation. Allowed elements and attributes are configurable in the InputfieldTinyMCE module settings. Pastefilter is only applied to content copied externally, from outside the TinyMCE field.


For some reason the github link I added in my first post was removed:


in which there is a request for making the purifier to configurable, but I don't fully understand this, therefor my request here.

Link to comment
Share on other sites

strange, It worked for me.
I pasted this and it got stripped with the default settings.
After adding video to the pastefilter whitelist it stays.

Which tags get stripped for you?

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.


Link to comment
Share on other sites

All except: Your browser does not support the video tag.

Everything is kept once Purifier is disabled. Having source and video in the pastefilter whitelist doesn't make any difference for me ?


Edit: something seems to be going absolutely wrong here, even when disabling purifier and pastefilter or editing pastefilter removing "i=em" a sourcecode insertion like this:

<i style="font-size:24px" class="fa">&#xf042;</i>


<em class="fa" style="font-size: 24px;"></em>


so for some reason these settings are obviously not applied.


Guess I am opening another topic for this issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...