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
[Html Sanitizer] There is no way to allow just any link scheme #49030
Comments
As I understand, @stof pointed out that having ability to too easily allow any scheme is not secure with just null as value. He suggested adding another property, which is similar to what I suggested in my issue. Definitely, having no ability to allow any URL scheme is very bad idea: the final decision about what's allowed and what's is not should be done always by the developer, not by sanitizing library creator. |
@TomaszGasior what is your use case for allowing any scheme (which will then accept links with a |
I don't want to add any restrictions to my users in regard of URL protocol. If |
Symfony version(s) affected
6.2.2
Description
Html Sanitizer has hard-coded default collection of protocols allowed in
<a href="url">
inHtmlSanitizerConfig
:There is a method
HtmlSanitizerConfig::allowLinkSchemes()
allowing to override it with custom list of allowed protocols. However, there is no way to just allow any protocol: to remove any restrictions from the URL's protocol.This is already supported by
UrlSanitizer::sanitize()
but there is no way to passnull
to$allowedSchemes
which would remove any protocol related restrictions.symfony/src/Symfony/Component/HtmlSanitizer/TextSanitizer/UrlSanitizer.php
Line 32 in 1f7bc10
symfony/src/Symfony/Component/HtmlSanitizer/TextSanitizer/UrlSanitizer.php
Line 51 in 1f7bc10
How to reproduce
Possible Solutions
HtmlSanitizerConfig::allowLinkSchemes()
and related fields & getters.allowAllLinkSchemes()
method.Additional Context
This may need to be handled also in framework bundle: currently empty value (null, empty array) of
framework.html_sanitizer.sanitizers.XXXX.allowed_link_schemes
causesHtmlSanitizerConfig::allowLinkSchemes()
to not be called at all.symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Line 2812 in 1f7bc10
The text was updated successfully, but these errors were encountered: