aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/utils/HtmlUtils.java3
-rw-r--r--tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java15
2 files changed, 18 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/HtmlUtils.java b/main/src/cgeo/geocaching/utils/HtmlUtils.java
index 8d4eed1..89b1070 100644
--- a/main/src/cgeo/geocaching/utils/HtmlUtils.java
+++ b/main/src/cgeo/geocaching/utils/HtmlUtils.java
@@ -20,6 +20,9 @@ public class HtmlUtils {
* @return
*/
public static String extractText(CharSequence html) {
+ if (StringUtils.isBlank(html)) {
+ return StringUtils.EMPTY;
+ }
String result = html.toString();
// recognize images in textview HTML contents
diff --git a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
new file mode 100644
index 0000000..3715c80
--- /dev/null
+++ b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
@@ -0,0 +1,15 @@
+package cgeo.geocaching.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import junit.framework.TestCase;
+
+public class HtmlUtilsTest extends TestCase {
+
+ public static void testExtractText() {
+ assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(null));
+ assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(StringUtils.EMPTY));
+ assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(" "));
+ }
+
+}