diff --git a/app/src/androidTest/java/de/test/antennapod/handler/AtomParserTest.java b/app/src/androidTest/java/de/test/antennapod/handler/AtomParserTest.java index 5a3be0374..de9f53ae2 100644 --- a/app/src/androidTest/java/de/test/antennapod/handler/AtomParserTest.java +++ b/app/src/androidTest/java/de/test/antennapod/handler/AtomParserTest.java @@ -1,12 +1,9 @@ package de.test.antennapod.handler; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import de.danoeh.antennapod.core.feed.Feed; import de.test.antennapod.util.syndication.feedgenerator.AtomGenerator; -import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator; import org.junit.Test; -import org.junit.runner.RunWith; import org.xmlpull.v1.XmlSerializer; import java.io.IOException; diff --git a/app/src/androidTest/java/de/test/antennapod/handler/RssParserTest.java b/app/src/androidTest/java/de/test/antennapod/handler/RssParserTest.java index b78d5770c..d137bb459 100644 --- a/app/src/androidTest/java/de/test/antennapod/handler/RssParserTest.java +++ b/app/src/androidTest/java/de/test/antennapod/handler/RssParserTest.java @@ -1,11 +1,9 @@ package de.test.antennapod.handler; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import de.danoeh.antennapod.core.feed.Feed; -import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator; +import de.test.antennapod.util.syndication.feedgenerator.Rss2Generator; import org.junit.Test; -import org.junit.runner.RunWith; import org.xmlpull.v1.XmlSerializer; import java.io.IOException; @@ -20,7 +18,7 @@ public class RssParserTest extends FeedParserTestBase { @Test public void testRss2Basic() throws Exception { Feed f1 = createTestFeed(10, true); - Feed f2 = runFeedTest(f1, new RSS2Generator(), "UTF-8", RSS2Generator.FEATURE_WRITE_GUID); + Feed f2 = runFeedTest(f1, new Rss2Generator(), "UTF-8", Rss2Generator.FEATURE_WRITE_GUID); feedValid(f1, f2, Feed.TYPE_RSS2); } @@ -29,7 +27,7 @@ public class RssParserTest extends FeedParserTestBase { String image = "https://example.com/image.png"; Feed f1 = createTestFeed(0, false); f1.setImageUrl(null); - Feed f2 = runFeedTest(f1, new RSS2Generator() { + Feed f2 = runFeedTest(f1, new Rss2Generator() { @Override protected void writeAdditionalAttributes(XmlSerializer xml) throws IOException { xml.startTag(null, "image"); diff --git a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java index 1dddca6b5..b989b519e 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java @@ -9,7 +9,7 @@ import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.test.antennapod.util.service.download.HTTPBin; -import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator; +import de.test.antennapod.util.syndication.feedgenerator.Rss2Generator; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -78,7 +78,7 @@ public class UITestUtils { private String hostFeed(Feed feed) throws IOException { File feedFile = new File(hostedFeedDir, feed.getTitle()); FileOutputStream out = new FileOutputStream(feedFile); - RSS2Generator generator = new RSS2Generator(); + Rss2Generator generator = new Rss2Generator(); generator.writeFeed(feed, out, "UTF-8", 0); out.close(); int id = server.serveFile(feedFile); diff --git a/app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/RSS2Generator.java b/app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/Rss2Generator.java similarity index 91% rename from app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/RSS2Generator.java rename to app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/Rss2Generator.java index ee664bfdc..a9a6f91e7 100644 --- a/app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/RSS2Generator.java +++ b/app/src/androidTest/java/de/test/antennapod/util/syndication/feedgenerator/Rss2Generator.java @@ -14,15 +14,19 @@ import de.danoeh.antennapod.core.util.DateUtils; /** * Creates RSS 2.0 feeds. See FeedGenerator for more information. */ -public class RSS2Generator implements FeedGenerator { +public class Rss2Generator implements FeedGenerator { public static final long FEATURE_WRITE_GUID = 1; @Override public void writeFeed(Feed feed, OutputStream outputStream, String encoding, long flags) throws IOException { - if (feed == null) throw new IllegalArgumentException("feed = null"); - if (outputStream == null) throw new IllegalArgumentException("outputStream = null"); - if (encoding == null) throw new IllegalArgumentException("encoding = null"); + if (feed == null) { + throw new IllegalArgumentException("feed = null"); + } else if (outputStream == null) { + throw new IllegalArgumentException("outputStream = null"); + } else if (encoding == null) { + throw new IllegalArgumentException("encoding = null"); + } XmlSerializer xml = Xml.newSerializer(); xml.setOutput(outputStream, encoding); diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java index 7aa5a90e7..7e4350fd4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.syndication.namespace.atom; import android.text.TextUtils; import android.util.Log; +import de.danoeh.antennapod.core.syndication.util.SyndStringUtils; import org.xml.sax.Attributes; import de.danoeh.antennapod.core.feed.FeedItem; @@ -163,12 +164,13 @@ public class NSAtom extends Namespace { if (state.getTagstack().size() >= 2) { AtomText textElement = null; - String content; + String contentRaw; if (state.getContentBuf() != null) { - content = state.getContentBuf().toString(); + contentRaw = state.getContentBuf().toString(); } else { - content = ""; + contentRaw = ""; } + String content = SyndStringUtils.trimAllWhitespace(contentRaw); SyndElement topElement = state.getTagstack().peek(); String top = topElement.getName(); SyndElement secondElement = state.getSecondTag(); @@ -181,9 +183,9 @@ public class NSAtom extends Namespace { if (ID.equals(top)) { if (FEED.equals(second) && state.getFeed() != null) { - state.getFeed().setFeedIdentifier(content); + state.getFeed().setFeedIdentifier(contentRaw); } else if (ENTRY.equals(second) && state.getCurrentItem() != null) { - state.getCurrentItem().setItemIdentifier(content); + state.getCurrentItem().setItemIdentifier(contentRaw); } } else if (TITLE.equals(top) && textElement != null) { if (FEED.equals(second) && state.getFeed() != null) {