From: Platonides Date: Tue, 22 Nov 2011 18:42:21 +0000 (+0000) Subject: Two decimal points may be valid, as 5..toString() == (5.).toString() X-Git-Tag: 1.31.0-rc.0~26349 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=6cac97e88ce5a49d129d6c85eea110e747c64d27;p=lhc%2Fweb%2Fwiklou.git Two decimal points may be valid, as 5..toString() == (5.).toString() Added some tests --- diff --git a/includes/libs/JavaScriptMinifier.php b/includes/libs/JavaScriptMinifier.php index d34473f363..fc815e2a9d 100644 --- a/includes/libs/JavaScriptMinifier.php +++ b/includes/libs/JavaScriptMinifier.php @@ -501,8 +501,8 @@ class JavaScriptMinifier { $end += strspn( $s, '0123456789', $end ); $decimal = strspn( $s, '.', $end ); if ($decimal) { - if ( $decimal > 1 ) { - return self::parseError($s, $end, 'The number has several decimal points' ); + if ( $decimal > 2 ) { + return self::parseError($s, $end, 'The number has too many decimal points' ); } $end += strspn( $s, '0123456789', $end ) + 1; } diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php index 5952e43284..8303e7979f 100644 --- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php +++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php @@ -84,6 +84,13 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { // And also per spec unicode char escape values should work in identifiers, // as long as it's a valid char. In future it might get normalized. array( "var Ka\\u015dSkatolVal = {}", 'var Ka\\u015dSkatolVal={}'), + + /* Some structures that might look invalid at first sight */ + 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();' ), ); }