Page MenuHomePhabricator

"string literal contains an unescaped line break" after minification
Closed, DuplicatePublicBUG REPORT

Description

Sorry to bother you twice with minification related bug reports today (this one and https://phabricator.wikimedia.org/T351610).

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

  • Add the attached OpenLayers 6.15.1 JavaScript library scripts array of ResourceModules in extension.json
  • This creates a JavaScript parsing error after minification: "Uncaught SyntaxError: "" string literal contains an unescaped line break
  • When doing the same with &debug=true added to the URL, no error occurs.

What happens?:

The minified Javascript contains a line break in a string (line 342, column 1000 of minified.js) - here the relevant part:

()=>{throw new Error("old style JPEG compression is not
supported.")}

What should have happened instead?:

There should be no line break in a string or the line break should be somehow escaped.

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

  • MediaWiki 1.39.5
  • It ships with minify 2.3.0

Other information (browser name/version, screenshots, etc.):

  • Input file (OpenLayers 6.15.1):
  • Minified version:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I can imagine that it's quite hard to write a fast minifier that can cope with alreay minified complex input, it might be an alternative to reconsider https://phabricator.wikimedia.org/T346701 .

There is await in the javascript source example and there was a bug about it T343499: Add minification support for async-await (ES2017), which is not deployed to wmf wikis yet. Could be fixed, needs testing with the newest version.

Thank you! I just tested whether the newest master branch (cfe7568b) fixes the problem by copying the content to the MediaWiki 1.39.5 vendor/wikimedia/minify folder and purging a page. I'm still getting the Uncaught SyntaxError: "" string literal contains an unescaped line break error.

@Phispi It is expected that async functions do not work today. This stands separate from the minifier because MediaWiki's browser support requires that. For example, the same syntax used in a regular JavaScript file would not pass the ESLint check.

I will merge this into T277675: Add native support for ES2016-ES2020 or higher versions as such.

Thank you for looking into this and sorry that I have caused work by creating a bug report for a behavior that is not supported by design. To my defense: I did check at https://doc.wikimedia.org/mediawiki-libs-Minify/master/ (the README.md file) whether any restriction in supported Ecmascript versions is listed. Thanks for pointing to the commonly agreed eslint configuration disallowing certain new features in the MediaWiki universe - I didn't know that.