stevebauman / purify

A Laravel wrapper for HTMLPurifier by ezyang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trix-editor config

AntonioPrimera opened this issue · comments

Hello,

I am using a trix-editor with Laravel 5.5 and, of course, the stevebauman/purify package to sanitize the html input.
There seems to be an issue with sanitizing attachments (uploaded images) in the trix editor. It seems to multiply the anchor tags, so instead of one anchor tag (before sanitizing), you get 5 anchor tags (after sanitizing).

Here is the content without sanitizing (what the trix-editor outputs):
before

And here is the content after purifying it:
after

I have added the proposed Service Provider for the Trix Editor, which seems to miss a few attributes, but this should not be a problem.

I've experienced this as well, but it could be an issue with HTML Purifier itself.

Are you able to debug?

The HTML Purifier is a large beast. I hoped to be able to avoid getting into more depth with it.

I'm now going through the HTML Purifier documentation and will try it directly with the same config. I'll update this issue as soon as I get some more insight.

Exactly my thoughts. I worked around this by only sanitizing content that doesn't contain attachments (which in my app is user provided content).

I personally wish there was a better option for purification in PHP, but it appears that HTML Purifier is the standard.

I found the issue and updated the config for the trix-editor, to work around the issue. I have posted it here:
HTML Purifier Issue 159

The bug is still there, but at least there is a quick fix for this and a hint towards finding the bug.

So, in short, just change the figure and figcaption elements in my previous gist to "Inline":
Working config

Thanks again @AntonioPrimera, I'll update the given provider in the readme with your working configuration.

Also gave credit where due: https://github.com/stevebauman/purify#custom-configuration-rules

If you'd prefer not to be mentioned, then just give me a shout 😄