Page MenuHomePhabricator

JS minification error with regular expressions
Closed, ResolvedPublic

Description

The JS minification interprets // in regular expressions as beginning a comment and so removes following code.

Example:

if (/\/commons\//.test($this.find('img').attr('src')))

is minified to

if(/\/commons\

Version: 1.17.x
Severity: critical

Details

Reference
bz27492

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:23 PM
bzimport set Reference to bz27492.
Schnark created this task.Feb 17 2011, 10:28 AM

http://translatewiki.net/w/load.php?debug=false&lang=nl&modules=site&only=scripts&skin=modern

jQuery(document).ready(function($){
var $this=$('#content');
if(/\/commons\

|> SyntaxError: Parse error

});
mediaWiki.loader.state({"site":"ready"});

This only fails for regexes which contain a slash at the end (causing //) AND contain a slash somewhere in the middle (causing the minifier to incorrectly regard it as the end of the regex).

Fixed in r82340