[go: nahoru, domu]

Page MenuHomePhabricator

User scripts are syntax-checked incorrectly before being sent to the browser
Closed, DuplicatePublic

Description

When a user script includes a "let"-scoped variable, it is replaced server-side with an error message, despite this being normal JavaScript (albeit fairly recent syntax).

For instance, the script at https://en.wikisource.org/w/index.php?title=User:Goldenshimmer/common.js&oldid=9499843 is sent to the browser as:

mw.loader.implement("user@17i0lov","mw.log.error(\"JavaScript parse error: Parse error: Missing ; before statement in file 'User:Goldenshimmer/common.js' on line 3\");");

rather than sending the script. Replacing the "let"-scoped variables with "var"-scoped variables fixed the issue.

Validating scripts server-side seems like needless complexity to me, and makes debugging more difficult. If it must be there, however, it should be kept up to date, and not explode with a borderline-nonsensical error message when confronted with modern JavaScript syntax.

Thanks!