aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java7
-rw-r--r--main/src/cgeo/geocaching/utils/TextUtils.java12
2 files changed, 16 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 2be811a..2fe9315 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -1694,11 +1694,12 @@ public abstract class GCParser {
// better to integrate those coordinates into the text rather than not
// display them at all.
final String latLon = entry.getString("LatLonString");
+ final String logText = (StringUtils.isEmpty(latLon) ? "" : (latLon + "<br/><br/>")) + TextUtils.removeControlCharacters(entry.getString("LogText"));
final LogEntry logDone = new LogEntry(
- entry.getString("UserName"),
+ TextUtils.removeControlCharacters(entry.getString("UserName")),
date,
LogType.getByIconName(logIconName),
- (StringUtils.isEmpty(latLon) ? "" : (latLon + "<br/><br/>")) + entry.getString("LogText"));
+ logText);
logDone.found = entry.getInt("GeocacheFindCount");
logDone.friend = friends;
@@ -1706,7 +1707,7 @@ public abstract class GCParser {
for (int i = 0; i < images.length(); i++) {
final JSONObject image = images.getJSONObject(i);
final String url = "http://img.geocaching.com/cache/log/large/" + image.getString("FileName");
- final String title = image.getString("Name");
+ final String title = TextUtils.removeControlCharacters(image.getString("Name"));
final Image logImage = new Image(url, title);
logDone.addLogImage(logImage);
}
diff --git a/main/src/cgeo/geocaching/utils/TextUtils.java b/main/src/cgeo/geocaching/utils/TextUtils.java
index 302a65d..14caf1d 100644
--- a/main/src/cgeo/geocaching/utils/TextUtils.java
+++ b/main/src/cgeo/geocaching/utils/TextUtils.java
@@ -153,4 +153,16 @@ public final class TextUtils {
return str.indexOf('<') != -1 || str.indexOf('&') != -1;
}
+ /**
+ * Remove all control characters (which are not valid in XML or HTML), as those should not appear in cache texts
+ * anyway
+ *
+ * @param input
+ * @return
+ */
+ public static String removeControlCharacters(final String input) {
+ Matcher remover = PATTERN_REMOVE_NONPRINTABLE.matcher(input);
+ return remover.replaceAll(" ").trim();
+ }
+
}