(Translated by https://www.hiragana.jp/)
⚓ T354385 Some Gadgets are broken after 1.42.0-wmf.12 update with incorrect error message
Page MenuHomePhabricator

Some Gadgets are broken after 1.42.0-wmf.12 update with incorrect error message
Closed, ResolvedPublicBUG REPORT

Description

In Arabic Wikipedia gadgets page we have 3 broken gadgets with incorrect error message "Contains one or more pages without .js, .css or .json suffix. They would not be used"

the same error in meta see gadgets page

some wikis have more broken gadgets and incoreect error messages see frwiki

Event Timeline

The message is from T353174: Specify all source pages in a single array in gadget definitions / 0c61a5a468ed9b6aafe939f60a60f9257db255e0
I would assume that was broken before without warning or it is working and the warning is a false positive.

It seems there is a LRM marker in the definition when the message is shown (for campaignEventPages and for common-special-search there is at least one)

For Arabic Wikipedia these gadgets are working before update and the warning is 100% false see Gadgets-definition

I have fixed the bug in Arabic Wikipedia , I was a space after page name and before new line see https://ar.wikipedia.org/w/index.php?title=Mediawiki:Gadgets-definition&diff=65607911&oldid=65607333
I noticed meta has U+200E after pages names
so only adding trim() to code will fix this bug.

Change 988036 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/Gadgets@master] Fix parsing logic when comments or hidden characters are present

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

It looks like the reason this worked prior to 0c61a5a468 (https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Gadgets/+/982772) is that we used to parse the entries as follows:

			if ( preg_match( '/\.json$/', $page ) ) {
				$info['datas'][] = $page;
			} elseif ( preg_match( '/\.js/', $page ) ) {
				$info['scripts'][] = $page;
			} elseif ( preg_match( '/\.css/', $page ) ) {
				$info['styles'][] = $page;
			}

Note that only .json has a`$` dollar sign for end match, the others allow partial matching and thus tolerate a trailing space, subpages, or any arbitrary suffix that starts the same way.

In the case of trailing spaces, this still ended up bundling a real page named without a trailing space, because Title::newFromText, just like for [[ Link ]] syntax and /wiki/Link_ pageview URLs, removes trailing whitespace.

In the case of non-space characters after the partially suffix, the page would have likely been discarded later on due to an invalid content type either way, so that use case doesn't matter I think.

In the case of non-space characters after the partially suffix, the page would have likely been discarded later on due to an invalid content type either way, so that use case doesn't matter I think.

Except if someone set the content type of a non-.js-suffix page manually to JavaScript, see T225468#7824548 (could someone finally unprotect that task? it turned out not to be a security issue, even less now that the suspicious code has been removed).

Change 987999 had a related patch set uploaded (by Krinkle; author: SD0001):

[mediawiki/extensions/Gadgets@wmf/1.42.0-wmf.12] Fix parsing logic when comments or hidden characters are present

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

Change 988036 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] Fix parsing logic when comments or hidden characters are present

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

Change 987999 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@wmf/1.42.0-wmf.12] Fix parsing logic when comments or hidden characters are present

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

Mentioned in SAL (#wikimedia-operations) [2024-01-08T15:24:58Z] <krinkle@deploy2002> Started scap: Backport for [[gerrit:987999|Fix parsing logic when comments or hidden characters are present (T354385)]]

Mentioned in SAL (#wikimedia-operations) [2024-01-08T15:26:24Z] <krinkle@deploy2002> krinkle: Backport for [[gerrit:987999|Fix parsing logic when comments or hidden characters are present (T354385)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-01-08T15:32:50Z] <krinkle@deploy2002> Finished scap: Backport for [[gerrit:987999|Fix parsing logic when comments or hidden characters are present (T354385)]] (duration: 07m 52s)