From: Brion Vibber Date: Wed, 23 Nov 2011 00:22:46 +0000 (+0000) Subject: Revert r103978, r103979 -- screwed something up, breaks jQuery minification. X-Git-Tag: 1.31.0-rc.0~26340 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=e97346ec18fa76b445f2f33d60cff924a5b47c1f;p=lhc%2Fweb%2Fwiklou.git 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. --- diff --git a/includes/libs/JavaScriptMinifier.php b/includes/libs/JavaScriptMinifier.php index 976c02feb9..baf9338542 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 f64cef70fc..ac62cb0959 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 d7d3cf4b76..d2bfeedfcf 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." );