Fix subscription deeplink (#7295)
- Properly extract url parameter - Remove prefix before looking it up in the database
This commit is contained in:
parent
3fe187eea5
commit
154099ef9d
|
@ -115,7 +115,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
username = savedInstanceState.getString("username");
|
||||
password = savedInstanceState.getString("password");
|
||||
}
|
||||
lookupUrlAndDownload(feedUrl);
|
||||
lookupUrlAndDownload(UrlChecker.prepareUrl(feedUrl));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue