Repository navigation
Check component style values like inline styles - #135
Merged
Merged
Conversation
malberts
force-pushed
the
fix/component-style-css-check
branch
from
October 29, 2026 11:39
7e93f80 to
16f6a9e
Compare
Component `style` values, and a card's `header-style`, `body-style` and `footer-style`, now get the CSS processing MediaWiki applies to inline styles in wikitext: after template expansion, they go through `Sanitizer::checkCss()`, in tags, parser functions and Lua (`mw.bootstrap.parse`) alike. Until now they reached the page unprocessed, so constructs MediaWiki removes from inline styles, such as `url()` or `image-set()`, still worked in components. Ordinary CSS still applies; a style value that uses such a construct is dropped as a whole, as in an inline style, leaving the component's built-in styles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
malberts
force-pushed
the
fix/component-style-css-check
branch
from
October 29, 2026 12:31
16f6a9e to
d90f9dc
Compare
malberts
marked this pull request as ready for review
October 29, 2026 12:45
Merged
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.
Component
stylevalues, and a card'sheader-style,body-styleandfooter-style, now get the CSS processing MediaWiki applies to inline styles in wikitext: after template expansion, they go throughSanitizer::checkCss(), in tags, parser functions and Lua (mw.bootstrap.parse) alike. Until now they reached the page unprocessed, so constructs MediaWiki removes from inline styles, such asurl()orimage-set(), still worked in components. Ordinary CSS still applies; a style value that uses such a construct is dropped as a whole, as in an inline style, leaving the component's built-in styles.Human input
Goal and shape: set by @malberts: align component styles with MediaWiki's processing of inline styles, even where a page relies on what it removes. Claude made the technical design within it.
Outcome: not reviewed by a human yet. Left for you: the code, in particular whether any user-supplied style reaches the output without going through
AttributeManager.Claude's calls
AttributeManager::CSS_VALUEkind for the four style attributes, in the one place attribute values are already validated.url()for local files only, which MediaWiki does not allow in inline styles either.{{#tag:nowiki|...}}, is now dropped as a whole, where it rendered garbled before; MediaWiki unstrips plain inline styles before its own check. Such a style is rare.Verification evidence
Test wiki: MediaWiki 1.43.11, PHP 8.3.36, Extension:Bootstrap 6.0.0.
ComponentStyleRenderingTestparses wikitext with the wiki's own parser. A style that template expansion turns intourl(//example.org/...)renders the URL before the fix and not after it; ordinary CSS renders in both. AnAttributeManagerTestcase covers the check directly. Without the check, or with the check moved before template expansion, these tests fail.style, parser-functionstyleand the card'sheader-style,body-styleandfooter-styleeach rendered aurl(//example.org/...)value; after it, none does.url(//example.org/...)style on an alert and a card header, the browser requested both images before the fix and none after it.width: 300px;on another alert is kept.{{#invoke:}}of a module callingmw.bootstrap.parse( 'alert', ..., { style = 'background:url(//example.org/lua.png)' } )renders the alert without the URL.