decode query-string by standard URLDecoder
This commit is contained in:
parent
04e2491f4d
commit
77ee79bdc3
2 changed files with 7 additions and 8 deletions
|
@ -5,9 +5,11 @@ import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -216,10 +218,11 @@ public class RouteServer extends Thread
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static HashMap<String,String> getUrlParams( String url )
|
private static HashMap<String,String> getUrlParams( String url ) throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
HashMap<String,String> params = new HashMap<String,String>();
|
HashMap<String,String> params = new HashMap<String,String>();
|
||||||
StringTokenizer tk = new StringTokenizer( url, "?&" );
|
String decoded = URLDecoder.decode( url, "UTF-8" );
|
||||||
|
StringTokenizer tk = new StringTokenizer( decoded, "?&" );
|
||||||
while( tk.hasMoreTokens() )
|
while( tk.hasMoreTokens() )
|
||||||
{
|
{
|
||||||
String t = tk.nextToken();
|
String t = tk.nextToken();
|
||||||
|
|
|
@ -73,18 +73,14 @@ public class ServerHandler extends RequestHandler {
|
||||||
|
|
||||||
String[] coords = lonLats.split("\\|");
|
String[] coords = lonLats.split("\\|");
|
||||||
if (coords.length < 2)
|
if (coords.length < 2)
|
||||||
coords = lonLats.split("%7C");
|
throw new IllegalArgumentException( "we need two lat/lon points at least!" );
|
||||||
if (coords.length < 2)
|
|
||||||
throw new IllegalArgumentException( "we need two lat/lon points at least!" );
|
|
||||||
|
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
||||||
for (int i = 0; i < coords.length; i++)
|
for (int i = 0; i < coords.length; i++)
|
||||||
{
|
{
|
||||||
String[] lonLat = coords[i].split(",");
|
String[] lonLat = coords[i].split(",");
|
||||||
if (lonLat.length < 2)
|
if (lonLat.length < 2)
|
||||||
lonLat = coords[i].split("%2C");
|
throw new IllegalArgumentException( "we need two lat/lon points at least!" );
|
||||||
if (lonLat.length < 2)
|
|
||||||
throw new IllegalArgumentException( "we need two lat/lon points at least!" );
|
|
||||||
wplist.add( readPosition( lonLat[0], lonLat[1], "via" + i ) );
|
wplist.add( readPosition( lonLat[0], lonLat[1], "via" + i ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue