aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2011-11-23 00:22:46 +0000
committerBrion Vibber <brion@users.mediawiki.org>2011-11-23 00:22:46 +0000
commite97346ec18fa76b445f2f33d60cff924a5b47c1f (patch)
tree6f6d28441eb54f64fb07d08bbf4c3b3e84558097
parent39fb9897130b444c239de97b203d9ff97b7271f5 (diff)
downloadmediawikicore-e97346ec18fa76b445f2f33d60cff924a5b47c1f.tar.gz
mediawikicore-e97346ec18fa76b445f2f33d60cff924a5b47c1f.zip
Revert r103978, r103979 -- screwed something up, breaks jQuery minification.
Incremented ResourceLoader::filterCacheVersion rather than decrementing to avoid potential confusion, especially since we already needed the incr.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/103988
-rw-r--r--includes/libs/JavaScriptMinifier.php16
-rw-r--r--includes/resourceloader/ResourceLoader.php2
-rw-r--r--tests/phpunit/includes/libs/JavaScriptMinifierTest.php11
3 files changed, 14 insertions, 15 deletions
diff --git a/includes/libs/JavaScriptMinifier.php b/includes/libs/JavaScriptMinifier.php
index 976c02feb93d..baf933854229 100644
--- a/includes/libs/JavaScriptMinifier.php
+++ b/includes/libs/JavaScriptMinifier.php
@@ -498,17 +498,19 @@ class JavaScriptMinifier {
ctype_digit( $ch )
|| ( $ch === '.' && $pos + 1 < $length && ctype_digit( $s[$pos + 1] ) )
) {
- $end += strspn( $s, '0123456789', $end, 1 );
+ $end += strspn( $s, '0123456789', $end );
$decimal = strspn( $s, '.', $end );
if ($decimal) {
- // If there are multiple decimal points, we only deal with the first one.
- // A following identifier is illegitimate after a raw . but a . and a property? Legit.
- // @fixme elsewhere in the code, if we find an identifier right after this - throw a parse error
- $end++;
- $end += strspn( $s, '0123456789', $end );
+ if ( $decimal > 2 ) {
+ return self::parseError($s, $end, 'The number has too many decimal points' );
+ }
+ $end += strspn( $s, '0123456789', $end + 1 ) + $decimal;
}
- $exponent = strspn( $s, 'eE', $end, 1 );
+ $exponent = strspn( $s, 'eE', $end );
if( $exponent ) {
+ if ( $exponent > 1 ) {
+ return self::parseError($s, $end, 'Number with several E' );
+ }
$end++;
// + sign is optional; - sign is required.
diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php
index f64cef70fcb0..ac62cb095962 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -29,7 +29,7 @@
class ResourceLoader {
/* Protected Static Members */
- protected static $filterCacheVersion = 6;
+ protected static $filterCacheVersion = 7;
protected static $requiredSourceProperties = array( 'loadScript' );
/** Array: List of module name/ResourceLoaderModule object pairs */
diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php
index d7d3cf4b76b5..d2bfeedfcf41 100644
--- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php
+++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php
@@ -89,14 +89,8 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
array( "var a = 5.;", "var a=5.;" ),
array( "5.0.toString();", "5.0.toString();" ),
array( "5..toString();", "5..toString();" ),
+ array( "5...toString();", false ),
array( "5.\n.toString();", '5..toString();' ),
-
- /* Some structures that are invalid, that we may not detect */
- //array( "5...toString();", false ), // can't detect this yet, though JSParser will throw error
- array( '5e1', '5e1' ),
- array( "5e", false ), // no exponent (end)
- array( "5eee1", false ), // no exponent (multiple e)
- array( "5e++", false ), // no exponent (other symbol)
);
}
@@ -107,7 +101,10 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
$minified = JavaScriptMinifier::minify( $code );
// JSMin+'s parser will throw an exception if output is not valid JS.
+ // suppression of warnings needed for stupid crap
+ wfSuppressWarnings();
$parser = new JSParser();
+ wfRestoreWarnings();
$parser->parse( $minified, 'minify-test.js', 1 );
$this->assertEquals( $expectedOutput, $minified, "Minified output should be in the form expected." );