Skip to content

Commit

Permalink
Don't confuse comments with regex
Browse files Browse the repository at this point in the history
Fixed #199
  • Loading branch information
matthiasmullie committed Sep 15, 2017
1 parent 678725d commit 134b25a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected function extractRegex()
(isset($match['after']) ? $match['after'] : '');
};

$pattern = '(?P<regex>\/.+?((?<!\\\\)\\\\\\\\)*\/[gimy]*)(?![0-9a-zA-Z\/])';
$pattern = '(?P<regex>\/(?!\/).+?((?<!\\\\)\\\\\\\\)*\/[gimy]*)(?![0-9a-zA-Z\/])';

// a regular expression can only be followed by a few operators or some
// of the RegExp methods (a `\` followed by a variable or value is
Expand Down
18 changes: 18 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,24 @@ function someOtherFunction() {
'if(!e.allow_html_data_urls&&V.test(k)&&!/^data:image\//i.test(k))return',
);

// https://github.com/matthiasmullie/minify/issues/199
$tests[] = array(
'// This case was fixed on version 1.3.50
// function () {
// return false;
// };
// Next two cases failed since version 1.3.49
// function () {
// return false; //.click();
// };
// function () {
// ;//;
// }',
'',
);

// known minified files to help doublecheck changes in places not yet
// anticipated in these tests
$files = glob(__DIR__.'/sample/minified/*.js');
Expand Down

0 comments on commit 134b25a

Please sign in to comment.