Page MenuHomePhabricator

Peast complains about backslash that is part of a regex in valid JS code
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Navigate to plwiki
  • Type mw.loader.load('ext.gadget.wp_sk-T358946') in browser console

What happens?:
An error is displayed in the console:

ext.gadget.wp_sk-script-0.js:
Parse error: Unexpected \ on line 910

What should have happened instead?:
The gadget should have been loaded as it used to before wmf.20 deployment

Software version (skip for WMF-hosted wikis like Wikipedia): wmf.20

Other information (browser name/version, screenshots, etc.):
The linter complains about this line: https://pl.wikipedia.org/wiki/MediaWiki:Gadget-sk.js#L-910 which is syntactically correct. The file hasn't been changed significantly for a few weeks and all the recent changes in that file were to overcome this error.

The error is present in ResourceLoader output, implying that the linter fails to recognize something in the code: https://pl.wikipedia.org/w/load.php?lang=pl&modules=ext.gadget.wp_sk-T358946&skin=vector

The error has been firstly reported after an hour of deploying MediaWiki 1.42-wmf.20 to plwiki.

(Edited the task to use a gadget copy, the main one has been hotfixed)

Event Timeline

which linter, the editor one, or the one that parses the page when you submit to save ?

This is about the Peast validator used by ResourceLoader at serve-time.

The one that's used by the ResourceLoader to ensure users won't get syntactically incorrect code. The one in the editor flags no error (only some warnings and infos and none of them is around the problematic 910th line).

The page can be saved without any trouble.

TheDJ renamed this task from MediaWiki JS linter complains about backslash in correct code to Peast complains about backslash that is part of a regex in valid JS code.Mar 2 2024, 10:23 AM

I reproduced locally, it's caused by the mck89/peast upgrade from T357477 (which fixed a different bug like this). That was already deployed a week ago, but I guess we cache these for a while.

Minimal test case: Peast\Peast::ES2016( '/=\n/' )->parse();

Upstream has been responsive. Could you file an upstream bug report?

Krinkle triaged this task as High priority.Mar 5 2024, 4:05 PM
Krinkle moved this task from Inbox to Confirmed Problem on the MediaWiki-ResourceLoader board.

Change 1008953 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Update mck89/peast to 1.16.2

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

Change 1008954 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/vendor@master] Update mck89/peast to 1.16.2

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

Change 1008954 merged by jenkins-bot:

[mediawiki/vendor@master] Update mck89/peast to 1.16.2

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

Change 1008953 merged by jenkins-bot:

[mediawiki/core@master] Update mck89/peast to 1.16.2

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

The fix will be deployed to Wikimedia wikis next week, between Tuesday and Thursday, per the usual schedule.