Browse Source

Verify that bbox longitude is not NaN.

sanitiser/_geo.js
	-The removal of the longitude sanitizer might result in a NaN
	longitude value passing through in the bbox. Add an `isNaN()`
	check.
wrap-longitude#56
Severyn Kozak 10 years ago
parent
commit
4ffdee1c00
  1. 17
      sanitiser/_geo.js

17
sanitiser/_geo.js

@ -51,14 +51,17 @@ function sanitize_bbox( clean, param ) {
if( Array.isArray( bboxArr ) && bboxArr.length === 4 ) { if( Array.isArray( bboxArr ) && bboxArr.length === 4 ) {
var bbox = bboxArr.map( function ( latlon ){ var bbox = [];
return parseFloat( latlon, 10 ); for( var ind = 0; ind < bboxArr.length; ind++ ){
}); var num = parseFloat( bboxArr[ ind ] );
bboxArr.forEach( function( latlon, index ) { if( isNaN( num ) ){
if( index % 2 === 1 && check_lat.is_invalid( latlon ) ){ return;
throw new Error( 'Invalid lat: ' + latlon );
} }
}); if( ind % 2 === 1 && check_lat.is_invalid( num ) ){
throw new Error( 'Invalid lat: ' + num );
}
bbox.push( num );
}
clean.bbox = { clean.bbox = {
right: Math.max( bbox[0], bbox[2] ), right: Math.max( bbox[0], bbox[2] ),

Loading…
Cancel
Save