diff --git a/api/src/androidTest/assets/localfeed/atom/atom_feed_no_url_siteurl.xml b/api/src/androidTest/assets/localfeed/atom/atom_feed_no_url_siteurl.xml
new file mode 100644
index 00000000..6b2d1530
--- /dev/null
+++ b/api/src/androidTest/assets/localfeed/atom/atom_feed_no_url_siteurl.xml
@@ -0,0 +1,7 @@
+
+
+ tag:github.com,2008:/readrops/Readrops/commits/develop
+ Recent Commits to Readrops:develop
+ 2020-09-06T21:09:59Z
+ Here is a subtitle
+
\ No newline at end of file
diff --git a/api/src/androidTest/assets/localfeed/rss1/rss1_feed_no_url_siteurl.xml b/api/src/androidTest/assets/localfeed/rss1/rss1_feed_no_url_siteurl.xml
new file mode 100644
index 00000000..dd49bb0c
--- /dev/null
+++ b/api/src/androidTest/assets/localfeed/rss1/rss1_feed_no_url_siteurl.xml
@@ -0,0 +1,31 @@
+
+
+
+ Slashdot
+ News for nerds, stuff that matters
+ en-us
+ Copyright 1997-2016, SlashdotMedia. All Rights Reserved.
+ 2020-09-23T16:20:20+00:00
+ Dice
+ help@slashdot.org
+ Technology
+ 1970-01-01T00:00+00:00
+ 1
+ hourly
+
+
+
+
+
+
+
+ Slashdot
+ https://a.fsdn.com/sd/topics/topicslashdot.gif
+ https://slashdot.org/
+
+
\ No newline at end of file
diff --git a/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt b/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt
index 9e90506d..f51ce144 100644
--- a/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt
+++ b/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt
@@ -96,6 +96,34 @@ class LocalRSSDataSourceTest {
assertEquals(pair.second.size, 10)
}
+ @Test
+ fun specialCasesAtomTest() {
+ val stream = context.resources.assets.open("localfeed/atom/atom_feed_no_url_siteurl.xml")
+
+ mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
+ .addHeader(LibUtils.CONTENT_TYPE_HEADER, "application/atom+xml")
+ .setBody(Buffer().readFrom(stream)))
+
+ val pair = localRSSDataSource.queryRSSResource(url.toString(), null)!!
+
+ assertEquals(pair.first.url, "http://localhost:8080/rss")
+ assertEquals(pair.first.siteUrl, "http://localhost")
+ }
+
+ @Test
+ fun specialCasesRSS1Test() {
+ val stream = context.resources.assets.open("localfeed/rss1/rss1_feed_no_url_siteurl.xml")
+
+ mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
+ .addHeader(LibUtils.CONTENT_TYPE_HEADER, "application/rdf+xml")
+ .setBody(Buffer().readFrom(stream)))
+
+ val pair = localRSSDataSource.queryRSSResource(url.toString(), null)!!
+
+ assertEquals(pair.first.url, "http://localhost:8080/rss")
+ assertEquals(pair.first.siteUrl, "http://localhost")
+ }
+
@Test
fun response304Test() {
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_MODIFIED))
diff --git a/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt b/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt
index 2a6b5af7..594857bb 100644
--- a/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt
+++ b/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt
@@ -63,6 +63,11 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) {
}
}
+ /**
+ * Checks if the provided url is a RSS resource
+ * @param url url to check
+ * @return true if [url] is a RSS resource, false otherwise
+ */
@WorkerThread
fun isUrlRSSResource(url: String): Boolean {
val response = queryUrl(url, null)
@@ -131,7 +136,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) {
// if an atom:link element was parsed, we still replace its value as it is unreliable,
// otherwise we just add the rss url
url = response.request.url.toString()
- } else if (type == LocalRSSHelper.RSSType.ATOM) {
+ } else if (type == LocalRSSHelper.RSSType.ATOM || type == LocalRSSHelper.RSSType.RSS_1) {
if (url == null) url = response.request.url.toString()
if (siteUrl == null) siteUrl = response.request.url.scheme + "://" + response.request.url.host
}
diff --git a/api/src/main/java/com/readrops/api/localfeed/rss1/RSS1FeedAdapter.kt b/api/src/main/java/com/readrops/api/localfeed/rss1/RSS1FeedAdapter.kt
index 697258c1..0b7e9cb0 100644
--- a/api/src/main/java/com/readrops/api/localfeed/rss1/RSS1FeedAdapter.kt
+++ b/api/src/main/java/com/readrops/api/localfeed/rss1/RSS1FeedAdapter.kt
@@ -19,7 +19,7 @@ class RSS1FeedAdapter : XmlAdapter {
return try {
konsume.child("RDF") {
allChildrenAutoIgnore("channel") {
- feed.url = attributes.getValue("about",
+ feed.url = attributes.getValueOpt("about",
namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
allChildrenAutoIgnore(names) {