Incremented ResourceLoader::filterCacheVersion rather than decrementing to avoid potential confusion, especially since we already needed the incr.
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.
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 */
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)
);
}
$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." );