From fc124633817d4d15cd6bf58487f19a1d73e64459 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 16 Dec 2013 12:48:31 +0100 Subject: integrate extremcaching.com * cherry-pick existing commits and have some basic tests * disable EC connector by default * fix faked geocodes during GPX import * parse wrongly encoded container size --- main/src/cgeo/geocaching/files/GPXParser.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'main/src/cgeo/geocaching/files') diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index 3e96291..4ebbb45 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -104,6 +104,10 @@ public abstract class GPXParser extends FileParser { */ private final Set result = new HashSet(100); private ProgressInputStream progressStream; + /** + * URL contained in the header of the GPX file. Used to guess where the file is coming from. + */ + protected String scriptUrl; private final class UserDataListener implements EndTextElementListener { private final int index; @@ -265,6 +269,14 @@ public abstract class GPXParser extends FileParser { final RootElement root = new RootElement(namespace, "gpx"); final Element waypoint = root.getChild(namespace, "wpt"); + root.getChild(namespace, "url").setEndTextElementListener(new EndTextElementListener() { + + @Override + public void end(String body) { + scriptUrl = body; + } + }); + // waypoint - attributes waypoint.setStartElementListener(new StartElementListener() { @@ -382,14 +394,19 @@ public abstract class GPXParser extends FileParser { } }); - // waypoint.getName() + // waypoint.name waypoint.getChild(namespace, "name").setEndTextElementListener(new EndTextElementListener() { @Override public void end(String body) { name = body; - final String content = body.trim(); + String content = body.trim(); + + // extremcaching.com manipulates the GC code by adding GC in front of ECxxx + if (StringUtils.startsWithIgnoreCase(content, "GCEC") && StringUtils.containsIgnoreCase(scriptUrl, "extremcaching")) { + content = content.substring(2); + } cache.setName(content); findGeoCode(cache.getName()); -- cgit v1.1