Skip to content
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

Trix-editor config #7

Closed
AntonioPrimera opened this issue Jan 10, 2018 · 5 comments
Closed

Trix-editor config #7

AntonioPrimera opened this issue Jan 10, 2018 · 5 comments

Comments

@AntonioPrimera
Copy link

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.

@stevebauman
Copy link
Owner

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

Are you able to debug?

@AntonioPrimera
Copy link
Author

AntonioPrimera commented Jan 11, 2018

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.

@stevebauman
Copy link
Owner

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.

@AntonioPrimera
Copy link
Author

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

@stevebauman
Copy link
Owner

stevebauman commented Jan 12, 2018

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants