Accept more malformed subscribtion URIs

This commit is contained in:
ByteHamster 2020-07-20 00:12:30 +02:00
parent 6079990643
commit 9d23279f47
2 changed files with 9 additions and 2 deletions

View File

@ -56,6 +56,13 @@ public class URLCheckerTest {
assertEquals("http://example.com", out);
}
@Test
public void testItpcProtocolWithScheme() {
final String in = "itpc://https://example.com";
final String out = URLChecker.prepareURL(in);
assertEquals("https://example.com", out);
}
@Test
public void testWhiteSpaceUrlShouldNotAppend() {
final String in = "\n http://example.com \t";

View File

@ -41,7 +41,7 @@ public final class URLChecker {
String lowerCaseUrl = url.toLowerCase(); // protocol names are case insensitive
if (lowerCaseUrl.startsWith("feed://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
return url.replaceFirst("feed://", "http://");
return prepareURL(url.substring("feed://".length()));
} else if (lowerCaseUrl.startsWith("pcast://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://");
return prepareURL(url.substring("pcast://".length()));
@ -50,7 +50,7 @@ public final class URLChecker {
return prepareURL(url.substring("pcast:".length()));
} else if (lowerCaseUrl.startsWith("itpc")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing itpc:// with http://");
return url.replaceFirst("itpc://", "http://");
return prepareURL(url.substring("itpc://".length()));
} else if (lowerCaseUrl.startsWith(AP_SUBSCRIBE)) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://");
return prepareURL(url.substring(AP_SUBSCRIBE.length()));