Skip to content

Conversation

tgalopin
Copy link
Contributor

@tgalopin tgalopin commented Feb 5, 2019

I would like to propose the usage of html-sanitizer in remplacement of HTMLPurifier.

html-sanitizer is well integrated in modern Symfony applications (autowiring / autoconfiguration), it is better suited than HTMLPurifier to sanitize user inputs such as Markdown, it is faster and it creates HTML that's simpler and easier to understand. It is also IMO easier to extends and configure.


public function __construct()
public function __construct(SanitizerInterface $sanitizer)
{
$this->parser = new \Parsedown();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just a nail-care, but Parsedown could be moved to constructor too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and thought it actually shouldn't be part of this PR, as it's not the same aim. I can definitely do another PR with a service for the parser though.

@javiereguiluz
Copy link
Member

Thanks Titouan for this proposal. The new library looks indeed better!

I made two quick profiles before/after making this change and performance improvements are nice too:

@javiereguiluz
Copy link
Member

Thank you Titouan.

@javiereguiluz javiereguiluz merged commit 13c5b03 into symfony:master Feb 15, 2019
javiereguiluz added a commit that referenced this pull request Feb 15, 2019
This PR was merged into the master branch.

Discussion
----------

Migrate from HTMLPurifier to html-sanitizer

I would like to propose the usage of html-sanitizer in remplacement of HTMLPurifier.

html-sanitizer is well integrated in modern Symfony applications (autowiring / autoconfiguration), it is better suited than HTMLPurifier to sanitize user inputs such as Markdown, it is faster and it creates HTML that's simpler and easier to understand. It is also IMO easier to extends and configure.

Commits
-------

13c5b03 Migrate from HTMLPurifier to html-sanitizer
@tgalopin tgalopin deleted the migrate-html-sanitizer branch February 15, 2019 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants