fix(framework): improve themeRoot validation#13354
Merged
Conversation
Collaborator
|
🧹 Preview deployment cleaned up: https://pr-13354--ui5-webcomponents.netlify.app |
vladitasev
approved these changes
Apr 1, 2026
Collaborator
|
🎉 This PR is included in version v2.21.0 🎉 The release is available on v2.21.0 Your semantic-release bot 📦🚀 |
nnaydenow
added a commit
that referenced
this pull request
Apr 16, 2026
Fix themeRoot validation to require explicit origin allowlist via meta tag
and separate configuration storage from validated URL usage.
Problem:
- themeRoot URLs were not properly validated for security
- getThemeRoot() mixed raw configuration with validated URLs
- Missing validation for relative paths and URL formats
Solution:
1. Require meta tag for all themeRoot usage:
<meta name="sap-allowed-theme-origins" content="https://cdn.example.com">
- Comma-separated list of allowed origins
- Wildcard "*" to allow any origin
- Legacy "sap-allowedThemeOrigins" (camelCase) supported
- Same-origin URLs allowed when meta tag present
2. Separate configuration from validation:
- getThemeRoot() returns raw configured value (unchanged)
- validateThemeRoot() performs security checks and normalization
- DOM link creation uses validated URL: {validatedRoot}/UI5/Base/baseLib/{theme}/css_variables.css
3. Enhanced validation:
- Absolute URLs: check origin against allowlist
- Relative paths (./path, ../path): resolve to current origin
- Absolute paths (/path): resolve to current origin
- Add trailing slash if missing
- Append /UI5/ to create proper theme asset path
- Return undefined for invalid/unauthorized URLs
4. Proper error handling:
- Log warning when validation fails
- No DOM link created for invalid themeRoot
- Graceful fallback to default theme behavior
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.
Fix themeRoot validation to require explicit origin allowlist via meta tag
and separate configuration storage from validated URL usage.
Problem:
Solution:
Require meta tag for all themeRoot usage:
Separate configuration from validation:
Enhanced validation:
Proper error handling: