From 91a03be6f4d337bdad6de7bd638b8521fc52face Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Mon, 25 Sep 2017 15:22:00 +1000 Subject: [PATCH] Allow any path when adding fdroidrepo(s):// intents. When explicitly given an fdroidrepo(s) intent, it seems silly to restrict it based on a path of /fdroid/repo, because it is plainly obvious it is an F-Droid repo. Manifest and NewRepoConfig both had to be amended to allow this behaviour. Fixes #1171. --- app/src/main/AndroidManifest.xml | 29 ++++++++++++++++--- .../org/fdroid/fdroid/data/NewRepoConfig.java | 16 ++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f6a6a23d5..e11473eec 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -424,6 +424,9 @@ query parameters. An alternative would be to do something like fdroidswap:// as a scheme, but then we need to copy/paste all of this intent-filter stuff and keep it up to date when it changes or a bug is found. + + This filter supports HTTP and HTTPS schemes. There is an additional filter for + fdroidrepo:// and fdroidrepos:// --> @@ -441,10 +444,6 @@ - - - - @@ -480,6 +479,28 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java b/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java index 5594a7d64..51a642be6 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java +++ b/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java @@ -76,21 +76,27 @@ public class NewRepoConfig { uri = Uri.parse(uri.toString().toLowerCase(Locale.ENGLISH)); } + // make scheme and host lowercase so they're readable in dialogs + scheme = scheme.toLowerCase(Locale.ENGLISH); + host = host.toLowerCase(Locale.ENGLISH); + + // We only listen for /fdroid/archive or /fdroid/repo paths when receiving a HTTP(S) intent. + // For fdroidrepo(s) intents, we are less picky and will accept any path. + boolean isHttpScheme = TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme); String path = uri.getPath(); - if (path == null || !(path.contains("/fdroid/archive") || path.contains("/fdroid/repo"))) { + if (path == null || isHttpScheme && !(path.contains("/fdroid/archive") || path.contains("/fdroid/repo"))) { isValidRepo = false; return; } - // make scheme and host lowercase so they're readable in dialogs - scheme = scheme.toLowerCase(Locale.ENGLISH); - host = host.toLowerCase(Locale.ENGLISH); + boolean isFdroidScheme = TextUtils.equals("fdroidrepo", scheme) || TextUtils.equals("fdroidrepos", scheme); + fingerprint = uri.getQueryParameter("fingerprint"); bssid = uri.getQueryParameter("bssid"); ssid = uri.getQueryParameter("ssid"); fromSwap = uri.getQueryParameter("swap") != null; - if (!Arrays.asList("fdroidrepos", "fdroidrepo", "https", "http").contains(scheme)) { + if (!isFdroidScheme && !isHttpScheme) { isValidRepo = false; return; }