Error
MediaWiki version: 1.35.0-wmf.41
Wikimedia\CSS\Objects\ComponentValueList may not contain tokens of type "[".
Impact
Notes
Happening on preview. Doesn't seem particularly impactful.
MediaWiki version: 1.35.0-wmf.41
Wikimedia\CSS\Objects\ComponentValueList may not contain tokens of type "[".
Happening on preview. Doesn't seem particularly impactful.
#0 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Objects/CSSObjectList.php(53): Wikimedia\CSS\Objects\ComponentValueList::testObjects(array) #1 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Sanitizer/StyleRuleSanitizer.php(163): Wikimedia\CSS\Objects\CSSObjectList->add(array) #2 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Sanitizer/Sanitizer.php(54): Wikimedia\CSS\Sanitizer\StyleRuleSanitizer->doSanitize(Wikimedia\CSS\Objects\QualifiedRule) #3 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Sanitizer/Sanitizer.php(110): Wikimedia\CSS\Sanitizer\Sanitizer->sanitizeObj(Wikimedia\CSS\Sanitizer\StyleRuleSanitizer, Wikimedia\CSS\Objects\QualifiedRule) #4 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Sanitizer/StylesheetSanitizer.php(108): Wikimedia\CSS\Sanitizer\Sanitizer->sanitizeRules(array, Wikimedia\CSS\Objects\RuleList) #5 /srv/mediawiki/php-1.35.0-wmf.41/vendor/wikimedia/css-sanitizer/src/Sanitizer/Sanitizer.php(138): Wikimedia\CSS\Sanitizer\StylesheetSanitizer->doSanitize(Wikimedia\CSS\Objects\RuleList) #6 /srv/mediawiki/php-1.35.0-wmf.41/extensions/TemplateStyles/includes/TemplateStylesContent.php(87): Wikimedia\CSS\Sanitizer\Sanitizer->sanitize(Wikimedia\CSS\Objects\Stylesheet) #7 /srv/mediawiki/php-1.35.0-wmf.41/extensions/TemplateStyles/includes/TemplateStylesHooks.php(356): TemplateStylesContent->sanitize(array) #8 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/Parser.php(3922): TemplateStylesHooks::handleTag(NULL, array, Parser, PPTemplateFrame_Hash) #9 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/PPFrame_Hash.php(330): Parser->extensionSubstitution(array, PPTemplateFrame_Hash) #10 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/PPTemplateFrame_Hash.php(89): PPFrame_Hash->expand(PPNode_Hash_Tree, integer) #11 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/Parser.php(3222): PPTemplateFrame_Hash->cachedExpand(string, PPNode_Hash_Tree) #12 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/PPFrame_Hash.php(253): Parser->braceSubstitution(array, PPFrame_Hash) #13 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/Parser.php(2887): PPFrame_Hash->expand(PPNode_Hash_Tree, integer) #14 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/Parser.php(1556): Parser->replaceVariables(string) #15 /srv/mediawiki/php-1.35.0-wmf.41/includes/parser/Parser.php(651): Parser->internalParse(string) #16 /srv/mediawiki/php-1.35.0-wmf.41/includes/content/WikitextContent.php(374): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer) #17 /srv/mediawiki/php-1.35.0-wmf.41/includes/content/AbstractContent.php(590): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput) #18 /srv/mediawiki/php-1.35.0-wmf.41/extensions/TemplateSandbox/includes/TemplateSandboxHooks.php(157): AbstractContent->getParserOutput(Title, integer, ParserOptions) #19 /srv/mediawiki/php-1.35.0-wmf.41/includes/HookContainer/HookContainer.php(320): TemplateSandboxHooks::templateSandboxPreview(EditPage, WikitextContent, string, NULL) #20 /srv/mediawiki/php-1.35.0-wmf.41/includes/HookContainer/HookContainer.php(131): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array) #21 /srv/mediawiki/php-1.35.0-wmf.41/includes/HookContainer/HookRunner.php(671): MediaWiki\HookContainer\HookContainer->run(string, array) #22 /srv/mediawiki/php-1.35.0-wmf.41/includes/EditPage.php(4099): MediaWiki\HookContainer\HookRunner->onAlternateEditPreview(EditPage, WikitextContent, string, NULL) #23 /srv/mediawiki/php-1.35.0-wmf.41/includes/EditPage.php(2954): EditPage->getPreviewText() #24 /srv/mediawiki/php-1.35.0-wmf.41/includes/EditPage.php(700): EditPage->showEditForm() #25 /srv/mediawiki/php-1.35.0-wmf.41/includes/actions/EditAction.php(71): EditPage->edit() #26 /srv/mediawiki/php-1.35.0-wmf.41/includes/actions/SubmitAction.php(38): EditAction->show() #27 /srv/mediawiki/php-1.35.0-wmf.41/includes/MediaWiki.php(527): SubmitAction->show() #28 /srv/mediawiki/php-1.35.0-wmf.41/includes/MediaWiki.php(313): MediaWiki->performAction(Article, Title) #29 /srv/mediawiki/php-1.35.0-wmf.41/includes/MediaWiki.php(940): MediaWiki->performRequest() #30 /srv/mediawiki/php-1.35.0-wmf.41/includes/MediaWiki.php(543): MediaWiki->main() #31 /srv/mediawiki/php-1.35.0-wmf.41/index.php(53): MediaWiki->run() #32 /srv/mediawiki/php-1.35.0-wmf.41/index.php(46): wfIndexMain() #33 /srv/mediawiki/w/index.php(3): require(string) #34 {main}
Change 627437 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/TemplateStyles@master] Fix incomplete "wrapper" a.k.a. "prependSelectors" validation
Change 627467 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[css-sanitizer@master] Fix incomplete ComponentValueList validation
Uh, neat. I had to dig for a while, but found a way to reproduce this: Go to enwiktionary:Template:acol, change the line
<templatestyles src="acol/styles.css" />
to
<templatestyles src="acol/styles.css" wrapper="a[href]" />
(that's a CSS selector for links that have a href attribute). Try to preview this. Boom. InvalidArgumentException.
I uploaded a few patches to make this surprising behavior more consistent, and surface it via a proper error message instead of an uncatched exception. Note that these patches intentionally do not change the current behavior. Selectors like the one in my example are still forbidden. Is this intentional? Probably not. But as long as we don't know I suggest to go with the fix, but open another TemplateStyles ticket to discuss what features should be allowed in <templatestyles wrapper=… attributes. Update: I found a much smaller fix that allows such selectors.
Change 627574 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/TemplateStyles@master] Fix wrapper="…" failing for more complex selectors
Change 627574 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Fix wrapper="…" failing for more complex selectors
Change 627467 abandoned by Thiemo Kreuz (WMDE):
[css-sanitizer@master] Fix incomplete ComponentValueList validation
Reason:
Change 627437 abandoned by Thiemo Kreuz (WMDE):
[mediawiki/extensions/TemplateStyles@master] Fix incomplete "wrapper" a.k.a. "prependSelectors" validation
Reason:
Change 634797 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/extensions/TemplateStyles@master] Fix type doc for the extra wrapper
Change 634797 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Fix type doc for the extra wrapper