From 4ffdee1c00fae6d823c9540d1b4d9842a6b10cfe Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Wed, 6 May 2015 10:37:47 -0400 Subject: [PATCH] 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. --- sanitiser/_geo.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sanitiser/_geo.js b/sanitiser/_geo.js index 2090ce5e..3c90c48e 100644 --- a/sanitiser/_geo.js +++ b/sanitiser/_geo.js @@ -51,14 +51,17 @@ function sanitize_bbox( clean, param ) { if( Array.isArray( bboxArr ) && bboxArr.length === 4 ) { - var bbox = bboxArr.map( function ( latlon ){ - return parseFloat( latlon, 10 ); - }); - bboxArr.forEach( function( latlon, index ) { - if( index % 2 === 1 && check_lat.is_invalid( latlon ) ){ - throw new Error( 'Invalid lat: ' + latlon ); + var bbox = []; + for( var ind = 0; ind < bboxArr.length; ind++ ){ + var num = parseFloat( bboxArr[ ind ] ); + if( isNaN( num ) ){ + return; } - }); + if( ind % 2 === 1 && check_lat.is_invalid( num ) ){ + throw new Error( 'Invalid lat: ' + num ); + } + bbox.push( num ); + } clean.bbox = { right: Math.max( bbox[0], bbox[2] ),