diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-06-13 19:31:16 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-06-13 19:31:27 +0200 |
commit | 76f59b8a23b64ac737259f57319c87b3016d80a7 (patch) | |
tree | 1a368a1bc45c31d1a7e2984498477f4fbc811b03 | |
parent | b51add0731ca57a07596358a23191fc7dda602f9 (diff) | |
download | cgeo-76f59b8a23b64ac737259f57319c87b3016d80a7.zip cgeo-76f59b8a23b64ac737259f57319c87b3016d80a7.tar.gz cgeo-76f59b8a23b64ac737259f57319c87b3016d80a7.tar.bz2 |
fix #2877: empty trackables page
-rw-r--r-- | main/src/cgeo/geocaching/utils/HtmlUtils.java | 3 | ||||
-rw-r--r-- | tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java | 15 |
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(" ")); + } + +} |