Merge pull request #4301 from ByteHamster/double-scheme

Accept more malformed subscribtion URIs
This commit is contained in:
H. Lehmann 2020-07-21 10:22:53 +02:00 committed by GitHub
commit 2339b2b8d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -56,6 +56,13 @@ public class URLCheckerTest {
assertEquals("http://example.com", out); 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 @Test
public void testWhiteSpaceUrlShouldNotAppend() { public void testWhiteSpaceUrlShouldNotAppend() {
final String in = "\n http://example.com \t"; 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 String lowerCaseUrl = url.toLowerCase(); // protocol names are case insensitive
if (lowerCaseUrl.startsWith("feed://")) { if (lowerCaseUrl.startsWith("feed://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://"); 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://")) { } else if (lowerCaseUrl.startsWith("pcast://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://"); if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://");
return prepareURL(url.substring("pcast://".length())); return prepareURL(url.substring("pcast://".length()));
@ -50,7 +50,7 @@ public final class URLChecker {
return prepareURL(url.substring("pcast:".length())); return prepareURL(url.substring("pcast:".length()));
} else if (lowerCaseUrl.startsWith("itpc")) { } else if (lowerCaseUrl.startsWith("itpc")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing itpc:// with http://"); 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)) { } else if (lowerCaseUrl.startsWith(AP_SUBSCRIBE)) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://"); if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://");
return prepareURL(url.substring(AP_SUBSCRIBE.length())); return prepareURL(url.substring(AP_SUBSCRIBE.length()));