-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][FrameworkBundle][TwigBundle] Add Twig filter, form-type extension and improve service definitions for HtmlSanitizer #46335
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
Conversation
src/Symfony/Component/Form/Extension/HtmlSanitizer/Type/TextTypeHtmlSanitizerExtension.php
Outdated
Show resolved
Hide resolved
c9083f9
to
d0482b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
(small comment: my email is galopintitouan@gmail.com now 😊)
d0482b6
to
213c03a
Compare
e4dfa22
to
b7def25
Compare
…ion and improve service definitions for HtmlSanitizer
b7def25
to
0ea89e5
Compare
PR is now tested and ready, failures unrelated. Status: needs review |
Thank you @nicolas-grekas. |
This PR was merged into the 2.x branch. Discussion ---------- Fix support for named closures As spotted by @stof on symfony/symfony#46335 (comment) Commits ------- 163f074 Fix support for named closures
} | ||
|
||
$sanitizers = $this->sanitizers; | ||
$sanitizer = $options['sanitizer'] ?? $this->defaultSanitizer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason not to configure $this->defaultSanitizer
as the default value in configureOptions()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: to make it clear that null
means "use the default value". I had removed the possibility to pass null before, and that made it impossible to say so.
This PR borrows the twig filter and the form-type extension from https://github.com/tgalopin/html-sanitizer-bundle/
Given the form builder (the input), it allows doing:
And on the template side (the output), it allows doing:
In order to be able to wire the corresponding services, I had to change the way html-sanitizer is wired by framework-bundle:
What we need here is a default name that we can rely on. By making the default name configurable, the current way to configure html_sanitizer makes it hard for other bundles (twig-bundle here) to know what the default name is. Eg here I would have to make the bundle read the config settings of framework-bundle. I solved this issue by making the default name non-configurable - aka I'm creating a convention: the default name is "default", and this "default" sanitizer is the one aliased to the html_sanitizer service, or to the non-named autowiring alias.
I'm submitting this PR to 6.1 because html-sanitizer is new. If we prefer merging this in 6.2, the updated service wiring must be merged into 6.1 at least.