resourceloader: Use "\n" instead of ";" as separator for scripts
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 28 Jun 2017 02:51:03 +0000 (19:51 -0700)
committerKrinkle <krinklemail@gmail.com>
Wed, 28 Jun 2017 03:59:05 +0000 (03:59 +0000)
commit483f13b226d88c6c36248a5988550c641b2a4153
treed80e1c336b82fd34f2d8a7274fb0502a1fb0d68b
parent39eda6770eb4813d21ded115240ccf5b7e58c0fd
resourceloader: Use "\n" instead of ";" as separator for scripts

This fixes two bugs:

* 1) When two modules are requested, and the first one ends with ";"
     inside a comment, the second module might become part of
     that comment.
* 2) A request with script=only where the requested module content
     ends in a statement without ";", but has a comment after it
     that does ends with a semicolon, then in debug=false, mw.loader.state()
     would be appended directly after the semicolon-less statement because
     the check is performed before minification.
     Previously:
     script> foo()
     script> // bar();
     states> mw.loader.state( {} );
     Became (minified separately):
     script> foo()
     states> mw.loader.state({});
     Became (concatenated)
     > foo()mw.loader.state();
     Which is invalid code.

Both of these are now fixed.

Bug: T162719
Change-Id: Ic8114c46ce232f5869400eaa40d3027003550533
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderModule.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderTest.php