Skip to content

[HtmlSanitizer] Information about subdomains of allowed hosts (they also match) #18379

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions html_sanitizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ URLs of ``<a>`` elements:
allowed_link_schemes: ['http', 'https', 'mailto']

# specifies the allowed hosts, the attribute will be dropped if the
# URL contains a different host
allowed_link_hosts: ['symfony.com']
# URL contains a different host which is not a subdomain of the allowed host
allowed_link_hosts: ['symfony.com'] # also allows any subdomain (i.e. www.symfony.com)

# whether to allow relative links (i.e. URLs without scheme and host)
allow_relative_links: true
Expand Down Expand Up @@ -763,7 +763,8 @@ URLs of ``<a>`` elements:
<allowed-link-scheme>mailto</allowed-link-scheme>

<!-- specifies the allowed hosts, the attribute will be dropped if the
URL contains a different host -->
URL contains a different host which is not a subdomain of the allowed host
Also allows any subdomain (i.e. www.symfony.com) -->
<allowed-link-host>symfony.com</allowed-link-host>
</framework:html-sanitizer>
</framework:config>
Expand All @@ -786,8 +787,8 @@ URLs of ``<a>`` elements:
->allowedLinkSchemes(['http', 'https', 'mailto'])

// specifies the allowed hosts, the attribute will be dropped if the
// URL contains a different host
->allowedLinkHost('symfony.com')
// URL contains a different host which is not a subdomain of the allowed host
->allowedLinkHost('symfony.com') // Also allows any subdomain (i.e. www.symfony.com)

// whether to allow relative links (i.e. URLs without scheme and host)
->allowRelativeLinks(true)
Expand All @@ -810,8 +811,8 @@ URLs of ``<a>`` elements:
->allowedLinkSchemes(['http', 'https', 'mailto'])

// specifies the allowed hosts, the attribute will be dropped if the
// URL contains a different host
->allowedLinkHosts(['symfony.com'])
// URL contains a different host which is not a subdomain of the allowed host
->allowedLinkHosts(['symfony.com']) // Also allows any subdomain (i.e. www.symfony.com)

// whether to allow relative links (i.e. URLs without scheme and host)
->allowRelativeLinks()
Expand Down Expand Up @@ -844,8 +845,8 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
allowed_media_schemes: ['http', 'https', 'mailto']

# specifies the allowed hosts, the attribute will be dropped if the URL
# contains a different host
allowed_media_hosts: ['symfony.com']
# contains a different host which is not a subdomain of the allowed host
allowed_media_hosts: ['symfony.com'] # Also allows any subdomain (i.e. www.symfony.com)

# whether to allow relative URLs (i.e. URLs without scheme and host)
allow_relative_medias: true
Expand Down Expand Up @@ -877,7 +878,8 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
<allowed-media-scheme>mailto</allowed-media-scheme>

<!-- specifies the allowed hosts, the attribute will be dropped if the URL
contains a different host -->
contains a different host which is not a subdomain of the allowed host.
Also allows any subdomain (i.e. www.symfony.com) -->
<allowed-media-host>symfony.com</allowed-media-host>
</framework:html-sanitizer>
</framework:config>
Expand All @@ -900,8 +902,8 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
->allowedMediaSchemes(['http', 'https', 'mailto'])

// specifies the allowed hosts, the attribute will be dropped if the URL
// contains a different host
->allowedMediaHost('symfony.com')
// contains a different host which is not a subdomain of the allowed host
->allowedMediaHost('symfony.com') // Also allows any subdomain (i.e. www.symfony.com)

// whether to allow relative URLs (i.e. URLs without scheme and host)
->allowRelativeMedias(true)
Expand All @@ -924,8 +926,8 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
->allowedMediaSchemes(['http', 'https', 'mailto'])

// specifies the allowed hosts, the attribute will be dropped if the URL
// contains a different host
->allowedMediaHosts(['symfony.com'])
// contains a different host which is not a subdomain of the allowed host
->allowedMediaHosts(['symfony.com']) // Also allows any subdomain (i.e. www.symfony.com)

// whether to allow relative URLs (i.e. URLs without scheme and host)
->allowRelativeMedias()
Expand Down