Conversation
Re-introduce URL-scheme validation for link and navigation sinks after the revert of #24371, using application-wide configuration plus a per-instance opt-out instead of the previous thread-unsafe static setter. Safe schemes are read from the new com.vaadin.safeUrlSchemes (InitParameters.URL_SAFE_SCHEMES) configuration property, defaulting to http, https, mailto, tel and ftp so that script-capable schemes such as javascript and data are rejected. Setting the property to "*" marks every scheme as safe and keeps the previous behaviour. Relative URLs are always considered safe; the scheme is extracted manually rather than via URI parsing so that valid relative URLs (e.g. containing spaces) are not falsely rejected. For trusted, hard-coded URLs whose scheme is not configured as safe, each sink offers an unsafe variant that bypasses validation: Anchor#setUnsafeHref, IFrame#setUnsafeSrc and Page#openUnsafe.
…cial exclusions in HtmlComponentSmokeTest
…inService is available in UrlUtil.isSafeUrl(String) Javadoc
…s in `Page.setLocation()` method
…or and IFrame constructors
…lidate URLs against safe schemes
- Add `openUnsafe_twoArg_opensWithoutValidation` test case to verify that the second argument ("_blank") is correctly passed as a parameter without validation.
- Ensure that the underlying `executeJs` method still receives both parameters in the expected order.
- Verify that custom safe schemes are respected when configured via deployment properties.
- Ensure a wildcard scheme pattern ("*") allows any URL scheme, including unsafe ones like "javascript".
…guration - Update javadoc in `UrlUtil.java` to explain that the wildcard entry `"*"` disables scheme validation even when mixed with other schemes. - Update javadoc in `InitParameters.java` to reflect that any configuration entry equal to `"*"` acts as a global override for safe schemes.
…ponent constructors - Assert that `Anchor` constructor throws `IllegalArgumentException` when provided with a URL using an unsafe scheme like "javascript", covering all constructor overloads including those with text and target arguments. - Assert that the `IFrame` constructor throws `IllegalArgumentException` when initialized with a source URL containing an unsafe scheme.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Re-introduce URL-scheme validation for link and navigation sinks after the revert of #24371, using application-wide configuration plus a per-instance opt-out instead of the previous thread-unsafe static setter.
Safe schemes are read from the new com.vaadin.safeUrlSchemes (InitParameters.URL_SAFE_SCHEMES) configuration property, defaulting to http, https, mailto, tel and ftp so that script-capable schemes such as javascript and data are rejected. Setting the property to "*" marks every scheme as safe and keeps the previous behaviour. Relative URLs are always considered safe; the scheme is extracted manually rather than via URI parsing so that valid relative URLs (e.g. containing spaces) are not falsely rejected.
For trusted, hard-coded URLs whose scheme is not configured as safe, each sink offers an unsafe variant that bypasses validation: Anchor#setUnsafeHref, IFrame#setUnsafeSrc and Page#openUnsafe.