Page MenuHomePhabricator

JS minifier incorrectly thinks an escaped backtick (\`) ends a template string
Closed, ResolvedPublicBUG REPORT

Description

For example, this code:

let a = `foo\`bar + baz`;

gets minified to:

let a=`foo\`bar+baz`;

But the spaces around the + shouldn't be removed because they're part of a literal. This happens because the minifier thinks the literal ends after the escaped backtick, even though it's escaped.

This causes minifier bugs in the development version of Vue 3.2.19 migration build, which contains a number of template strings that look like:

`Use \`import { reactive } from "vue"\` from Composition API instead.`,

Event Timeline

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

Change 739960 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/libs/Minify@master] JavaScriptMinifier: Correctly recognize \\` in template strings

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

Change 739960 merged by jenkins-bot:

[mediawiki/libs/Minify@master] JavaScriptMinifier: Correctly recognize \\` in template strings

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

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

[mediawiki/libs/Minify@master] Tag 2.2.6

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

Krinkle triaged this task as High priority.

Change 740234 merged by jenkins-bot:

[mediawiki/libs/Minify@master] Tag 2.2.6

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

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

[mediawiki/core@master] resourceloader: Update wikimedia/minify to 2.2.6

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

Change 740243 merged by jenkins-bot:

[mediawiki/core@master] resourceloader: Update wikimedia/minify to 2.2.6

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

Change 747523 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] ResourceLoader: Increment CACHE_VERSION for wikimedia/minify 2.2.6

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

Change 747523 merged by jenkins-bot:

[mediawiki/core@master] resourceloader: Increment CACHE_VERSION for wikimedia/minify 2.2.6

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