keep Uri "path" intact during parsing for consistant regexes

By not modifying "path" from what Uri.getPath() returns, it keeps the
pattern matching consistent since the contents of "path" will always be the
same as Uri.getPath(), and what is visible in the URI itself.
This commit is contained in:
Hans-Christoph Steiner 2015-01-16 10:22:52 +01:00
parent 2771da35de
commit d34d341d65

View file

@ -642,14 +642,16 @@ public class GeoPointParserUtil {
String path = uri.getPath();
if (path == null) {
path = "";
} else if (path.startsWith("/")) {
path = path.substring(1);
}
String fragment = uri.getFragment();
String query = uri.getQuery();
if(query == null) {
// DOUBLE check this may be wrong test of openstreetmap.de (looks very weird url and server doesn't respond)
query = path;
if (path.startsWith("/")) {
query = path.substring(1);
} else {
query = path;
}
}
Map<String, String> params = new HashMap<String, String>();
@ -672,9 +674,9 @@ public class GeoPointParserUtil {
if (host.equals("osm.org") || host.endsWith("openstreetmap.org")) {
Pattern p;
Matcher matcher;
if (path.startsWith("go/")) { // short URL form
if (path.startsWith("/go/")) { // short URL form
p = Pattern.compile("^/go/([A-Za-z0-9_@~]+-*)(?:.*)");
matcher = p.matcher(uri.getPath());
matcher = p.matcher(path);
if (matcher.matches()) {
return MapUtils.decodeShortLinkString(matcher.group(1));
}