From 9c2a1dc37f2e16f27b8012a193c6258ec962c333 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Fri, 16 Mar 2012 09:07:03 +0100 Subject: [PATCH] implemented several security measures when parsing GET input to the site --- WebContent/main.js | 75 +++++++++++++++++++++++++-------------------- WebContent/utils.js | 16 ++++++++++ 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/WebContent/main.js b/WebContent/main.js index 7949f40fa..d4d97836d 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -176,41 +176,50 @@ function initMap() { // parse URL GET parameters if any exist function checkURL(){ var called_url = document.location.search.substr(1,document.location.search.length); - if( called_url != '') { - var positions = []; - - var destination = undefined; - var destination_name = undefined; + + // reject messages that are clearly too long or too small + if( called_url.length > 1000 || called_url.length == 0) + return; + + // storage for parameter values + var positions = []; + var destination = undefined; + var destination_name = undefined; - // parse input (currently only parses start, dest, via) - var splitted_url = called_url.split('&'); - for(var i=0; i]+(>|$)/g ,""); // discard tags + } + } - // destination given - if( destination != undefined ) { - onclickGeocoderResult("target", destination.lat, destination.lng, (destination_name == undefined) ); - if( destination_name != undefined ) - document.getElementById("input-target-name").value = decodeURI(destination_name); - return; - } + // case 1: destination given + if( destination != undefined ) { + onclickGeocoderResult("target", destination.lat, destination.lng, (destination_name == undefined) ); + if( destination_name != undefined ) + document.getElementById("input-target-name").value = destination_name; + return; + } + // case 2: locations given + if( positions != []) { // draw via points if( positions.length > 0) my_markers.setSource( positions[0] ); @@ -220,10 +229,10 @@ function checkURL(){ my_markers.setVia( i-1, positions[i] ); for(var i=0; i=-90 && value <=90) + return true; + else + return false; +} +function isLongitude(value) { + if( value >=-180 && value <=180) + return true; + else + return false; +} + // ------------------------------------------------------ // distance between two points