Page MenuHomePhabricator

Wikimedia\CSS\Objects\ComponentValueList may not contain tokens of type "[".
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.35.0-wmf.41

message
Wikimedia\CSS\Objects\ComponentValueList may not contain tokens of type "[".

Impact

Notes

Happening on preview. Doesn't seem particularly impactful.

Details

Request ID
02eca51d-2d98-4259-936e-45728db09800
Request URL
https://en.wiktionary.org/w/index.php?title=Template:topa&action=submit
Stack Trace
exception.trace
#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}

Event Timeline

jeena created this task.Jul 15 2020, 6:09 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 15 2020, 6:09 PM

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

https://gerrit.wikimedia.org/r/627437

Change 627467 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[css-sanitizer@master] Fix incomplete ComponentValueList validation

https://gerrit.wikimedia.org/r/627467

thiemowmde added a subscriber: thiemowmde.

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

https://gerrit.wikimedia.org/r/627574

Change 627574 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Fix wrapper="…" failing for more complex selectors

https://gerrit.wikimedia.org/r/627574

Jdforrester-WMF closed this task as Resolved.Oct 15 2020, 5:26 PM
Jdforrester-WMF assigned this task to thiemowmde.
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

This is provisionally fixed in the next train. Thank you, Thiemo!

Change 627467 abandoned by Thiemo Kreuz (WMDE):
[css-sanitizer@master] Fix incomplete ComponentValueList validation

Reason:

https://gerrit.wikimedia.org/r/627467

Change 627437 abandoned by Thiemo Kreuz (WMDE):
[mediawiki/extensions/TemplateStyles@master] Fix incomplete "wrapper" a.k.a. "prependSelectors" validation

Reason:

https://gerrit.wikimedia.org/r/627437

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

https://gerrit.wikimedia.org/r/634797

Change 634797 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Fix type doc for the extra wrapper

https://gerrit.wikimedia.org/r/634797