summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-07-19 23:49:55 +0200
committerGitHub <noreply@github.com>2024-07-19 23:49:55 +0200
commit154099ef9d413b5952ced2165298d1dc0ca75d98 (patch)
tree29a63e9955ce8b18ea9d3b1c31eb949bee1ccff8
parent3fe187eea53691b357e0082e481879e52ecab529 (diff)
downloadAntennaPod-154099ef9d413b5952ced2165298d1dc0ca75d98.zip
Fix subscription deeplink (#7295)
- Properly extract url parameter - Remove prefix before looking it up in the database
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/share/ShareUtils.java11
-rw-r--r--net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java6
-rw-r--r--net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java3
4 files changed, 12 insertions, 10 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java
index be601027c..7e994b1ed 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java
@@ -115,7 +115,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
username = savedInstanceState.getString("username");
password = savedInstanceState.getString("password");
}
- lookupUrlAndDownload(feedUrl);
+ lookupUrlAndDownload(UrlChecker.prepareUrl(feedUrl));
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/share/ShareUtils.java b/app/src/main/java/de/danoeh/antennapod/ui/share/ShareUtils.java
index 7b685f8bc..1a2614227 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/share/ShareUtils.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/share/ShareUtils.java
@@ -35,12 +35,11 @@ public class ShareUtils {
}
public static void shareFeedLink(Context context, Feed feed) {
- String text = feed.getTitle()
- + "\n\n"
- + "https://antennapod.org/deeplink/subscribe/?url="
- + URLEncoder.encode(feed.getDownloadUrl())
- + "&title="
- + URLEncoder.encode(feed.getTitle());
+ String feedurl = URLEncoder.encode(feed.getDownloadUrl());
+ feedurl = feedurl.replace("htt", "%68%74%74"); // To not confuse users by having a url inside a url
+ String text = feed.getTitle() + "\n\n"
+ + "https://antennapod.org/deeplink/subscribe/?url=" + feedurl
+ + "&title=" + URLEncoder.encode(feed.getTitle());
shareLink(context, text);
}
diff --git a/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java b/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java
index d66f8e74a..79116f00d 100644
--- a/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java
+++ b/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java
@@ -56,11 +56,11 @@ public final class UrlChecker {
return prepareUrl(url.substring(AP_SUBSCRIBE.length()));
} else if (lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK)) {
Log.d(TAG, "Removing " + AP_SUBSCRIBE_DEEPLINK);
- String removedWebsite = url.substring(url.indexOf("?url=") + "?url=".length());
+ String query = Uri.parse(url).getQueryParameter("url");
try {
- return prepareUrl(URLDecoder.decode(removedWebsite, "UTF-8"));
+ return prepareUrl(URLDecoder.decode(query, "UTF-8"));
} catch (UnsupportedEncodingException e) {
- return prepareUrl(removedWebsite);
+ return prepareUrl(query);
}
} else if (!(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://"))) {
Log.d(TAG, "Adding http:// at the beginning of the URL");
diff --git a/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java b/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java
index a00ae6dcb..e2eef4eb2 100644
--- a/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java
+++ b/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java
@@ -114,6 +114,9 @@ public class UrlCheckerTest {
+ URLEncoder.encode(feed, "UTF-8")));
assertEquals(feed, UrlChecker.prepareUrl("http://www.antennapod.org/deeplink/subscribe?url="
+ "example.org/podcast.rss"));
+ assertEquals(feed, UrlChecker.prepareUrl("https://antennapod.org/deeplink/subscribe?url=" + feed + "&title=a"));
+ assertEquals(feed, UrlChecker.prepareUrl("https://antennapod.org/deeplink/subscribe?url="
+ + URLEncoder.encode(feed) + "&title=a"));
}
@Test