r103937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103936‎ | r103937 | r103938 >
Date:18:42, 22 November 2011
Author:platonides
Status:ok
Tags:
Comment:
Two decimal points may be valid, as 5..toString() == (5.).toString()
Added some tests
Modified paths:
  • /trunk/phase3/includes/libs/JavaScriptMinifier.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php
@@ -84,6 +84,13 @@
8585 // And also per spec unicode char escape values should work in identifiers,
8686 // as long as it's a valid char. In future it might get normalized.
8787 array( "var Ka\\u015dSkatolVal = {}", 'var Ka\\u015dSkatolVal={}'),
 88+
 89+ /* Some structures that might look invalid at first sight */
 90+ array( "var a = 5.;", "var a=5.;" ),
 91+ array( "5.0.toString();", "5.0.toString();" ),
 92+ array( "5..toString();", "5..toString();" ),
 93+ array( "5...toString();", false ),
 94+ array( "5.\n.toString();", '5..toString();' ),
8895 );
8996 }
9097
Index: trunk/phase3/includes/libs/JavaScriptMinifier.php
@@ -501,8 +501,8 @@
502502 $end += strspn( $s, '0123456789', $end );
503503 $decimal = strspn( $s, '.', $end );
504504 if ($decimal) {
505 - if ( $decimal > 1 ) {
506 - return self::parseError($s, $end, 'The number has several decimal points' );
 505+ if ( $decimal > 2 ) {
 506+ return self::parseError($s, $end, 'The number has too many decimal points' );
507507 }
508508 $end += strspn( $s, '0123456789', $end ) + 1;
509509 }

Status & tagging log