Last modified: 2012-02-01 08:50:59 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T34548, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32548 - Possible bug in minifier: exponents can be incorrectly broken across lines
Possible bug in minifier: exponents can be incorrectly broken across lines
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Brion Vibber
https://translatewiki.net/wiki/Map_of...
:
: 34048 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-21 15:04 UTC by Niklas Laxström
Modified: 2012-02-01 08:50 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Provisional patch to JavaScriptMinifier.php (3.33 KB, patch)
2011-11-21 23:00 UTC, Brion Vibber
Details
Provisional patch to JavaScriptMinifier.php, fixed (1.96 KB, patch)
2011-11-21 23:01 UTC, Brion Vibber
Details

Description Niklas Laxström 2011-11-21 15:04:55 UTC
When I visit the above url I get:
load.php:682 Uncaught SyntaxError: Unexpected token -

I don't get an error with debug=true
Comment 1 Brion Vibber 2011-11-21 18:51:22 UTC
Error I see in Firefox is:

missing exponent
https://translatewiki.net/w/load.php?debug=false&lang=en&modules=ext.maps.common%2Copenlayers&skin=vector&version=20111120T223129Z&*
Line 681


original source (<https://translatewiki.net/w/extensions/Maps/includes/services/OpenLayers/OpenLayers/OpenLayers.js> line 1483):

OpenLayers.Layer.MultiMap=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[9,1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,6.866455078125E-4,3.4332275390625E-4,1.71661376953125E-4,8.58306884765625E-5,4.291534423828125E-5],type:null,initialize:function(a,b){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);




Minified broken (<https://translatewiki.net/w/load.php?debug=false&lang=en&modules=ext.maps.common%2Copenlayers&skin=vector&version=20111120T223129Z&*> line 681-682):

"Scale = 1 : ${scaleDenom}":"Escala = 1 : ${scaleDenom}",W:"O",E:"E",N:"N",S:"S",reprojectDeprecated:"Est\u00e1 usando a op\u00e7\u00e3o 'reproject' na camada ${layerName}. Esta op\u00e7\u00e3o \u00e9 obsoleta: foi concebida para permitir a apresenta\u00e7\u00e3o de dados sobre mapas-base comerciais, mas esta funcionalidade \u00e9 agora suportada pelo Mercator Esf\u00e9rico. Mais informa\u00e7\u00e3o est\u00e1 dispon\u00edvel em http://trac.openlayers.org/wiki/SphericalMercator.",methodDeprecated:"Este m\u00e9todo foi declarado obsoleto e ser\u00e1 removido na vers\u00e3o 3.0. Por favor, use ${newMethod} em vez disso."});OpenLayers.Layer.MultiMap=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[9,1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,6.866455078125E-4,3.4332275390625E-4,1.71661376953125E-4,8.58306884765625E
-5,4.291534423828125E-5],type:null,initialize:function(a,b)

^ note the line break between "8.58306884765625E" and "-5".
Comment 2 Brion Vibber 2011-11-21 19:25:43 UTC
I suspect it's hitting this line-wrapping bit:

} elseif( $maxLineLength > 0 && $lineLength + $end - $pos > $maxLineLength &&
		!isset( $semicolon[$state][$type] ) && $type !== self::TYPE_INCR_OP )
{
	// This line would get too long if we added $token, so add a newline first.
	// Only do this if it won't trigger semicolon insertion and if it won't
	// put a postfix increment operator on its own line, which is illegal in js.
	$out .= "\n";
	$lineLength = 0;

which probably indicates that the tokenizer stage is incorrectly splitting numbers with exponents into two or three tokens, where the number part of the exponent is separate and ends up getting pushed to the next line.

The entire number, including the E, sign, and exponent, should come out as single token.

Well isn't this suspicious!

	// Numeric literal. Search for the end of it, but don't care about [+-]exponent
	// at the end, as the results of "numeric [+-] numeric" and "numeric" are
	// identical to our state machine.
Comment 3 Brion Vibber 2011-11-21 22:01:49 UTC
Working on a test case...
Comment 4 Brion Vibber 2011-11-21 22:20:36 UTC
Added PHPUnit test cases in 103846. This will trigger 2 test failures until the bug is resolved.
Comment 5 Brion Vibber 2011-11-21 23:00:21 UTC
Created attachment 9518 [details]
Provisional patch to JavaScriptMinifier.php

Passes the PHPUnit test cases; want to test it on actual code though :D
Comment 6 Brion Vibber 2011-11-21 23:01:45 UTC
Created attachment 9519 [details]
Provisional patch to JavaScriptMinifier.php, fixed

removed stray edits to other files
Comment 7 Brion Vibber 2011-11-21 23:09:25 UTC
Ok tested it with the same file that broke on translatewiki (from Maps extension).

http://stormcloud.local/trunk/load.php?debug=false&lang=en&modules=ext.maps.common%2Copenlayers&skin=vector&version=20111120T223129Z

With the original code I see at line 681/682:

"Scale = 1 : ${scaleDenom}":"Escala = 1 : ${scaleDenom}",W:"O",E:"E",N:"N",S:"S",reprojectDeprecated:"Est\u00e1 usando a op\u00e7\u00e3o 'reproject' na camada ${layerName}. Esta op\u00e7\u00e3o \u00e9 obsoleta: foi concebida para permitir a apresenta\u00e7\u00e3o de dados sobre mapas-base comerciais, mas esta funcionalidade \u00e9 agora suportada pelo Mercator Esf\u00e9rico. Mais informa\u00e7\u00e3o est\u00e1 dispon\u00edvel em http://trac.openlayers.org/wiki/SphericalMercator.",methodDeprecated:"Este m\u00e9todo foi declarado obsoleto e ser\u00e1 removido na vers\u00e3o 3.0. Por favor, use ${newMethod} em vez disso."});OpenLayers.Layer.MultiMap=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[9,1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,6.866455078125E-4,3.4332275390625E-4,1.71661376953125E-4,8.58306884765625E
-5,4.291534423828125E-5],type:null,initialize:function(a,b){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);this.sphericalMercator&&(OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator),this.initMercatorParameters(),this.RESOLUTIONS.unshift(10))},loadMapObject:function(){try{this.mapObject=new MultimapViewer(this.div)}catch(a){}},getWarningHTML:function(){return OpenLayers.i18n("getLayerWarning",{layerType:"MM",layerLib:"MultiMap"})},setMapObjectCenter:function(a,b){this.mapObject.goToPosition(a,b)},getMapObjectCenter:function(){return this.mapObject.getCurrentPosition()},getMapObjectZoom:function(){return this.mapObject.getZoomFactor()},getMapObjectLonLatFromMapObjectPixel:function(a){a.x-=this.map.getSize().w/2;a.y-=this.map.getSize().h/2;return this.mapObject.getMapPositionAt(a)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.geoPosToContainerPixels(a)

^ that's split between the 'E' and the '-5', as we saw before.


With the patch in & memcached cleared, reload & we get:

"Scale = 1 : ${scaleDenom}":"Escala = 1 : ${scaleDenom}",W:"O",E:"E",N:"N",S:"S",reprojectDeprecated:"Est\u00e1 usando a op\u00e7\u00e3o 'reproject' na camada ${layerName}. Esta op\u00e7\u00e3o \u00e9 obsoleta: foi concebida para permitir a apresenta\u00e7\u00e3o de dados sobre mapas-base comerciais, mas esta funcionalidade \u00e9 agora suportada pelo Mercator Esf\u00e9rico. Mais informa\u00e7\u00e3o est\u00e1 dispon\u00edvel em http://trac.openlayers.org/wiki/SphericalMercator.",methodDeprecated:"Este m\u00e9todo foi declarado obsoleto e ser\u00e1 removido na vers\u00e3o 3.0. Por favor, use ${newMethod} em vez disso."});OpenLayers.Layer.MultiMap=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[9,1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,6.866455078125E-4,3.4332275390625E-4,1.71661376953125E-4,
8.58306884765625E-5,4.291534423828125E-5],type:null,initialize:function(a,b){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);this.sphericalMercator&&(OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator),this.initMercatorParameters(),this.RESOLUTIONS.unshift(10))},loadMapObject:function(){try{this.mapObject=new MultimapViewer(this.div)}catch(a){}},getWarningHTML:function(){return OpenLayers.i18n("getLayerWarning",{layerType:"MM",layerLib:"MultiMap"})},setMapObjectCenter:function(a,b){this.mapObject.goToPosition(a,b)},getMapObjectCenter:function(){return this.mapObject.getCurrentPosition()},getMapObjectZoom:function(){return this.mapObject.getZoomFactor()},getMapObjectLonLatFromMapObjectPixel:function(a){a.x-=this.map.getSize().w/2;a.y-=this.map.getSize().h/2;return this.mapObject.getMapPositionAt(a)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.

^ this looks correct. Yay!
Comment 8 Brion Vibber 2011-11-21 23:18:09 UTC
Committed fix as r103865. I wouldn't mind some more test cases though; the minifier's tokenizer doesn't report parse errors so feels really skeezy to me. :)
Comment 9 Michael M. 2012-02-01 08:50:59 UTC
*** Bug 34048 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links