make all incoming repo URLs all lowercase
This commit is contained in:
parent
ffc1f27e33
commit
e063636d61
@ -116,13 +116,25 @@ public class ManageRepo extends ListActivity {
|
|||||||
/* an URL from a click or a QRCode scan */
|
/* an URL from a click or a QRCode scan */
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
// scheme should only ever be pure ASCII:
|
// scheme should only ever be pure ASCII aka Locale.ENGLISH
|
||||||
String scheme = intent.getScheme().toLowerCase(Locale.ENGLISH);
|
String scheme = intent.getScheme().toLowerCase(Locale.ENGLISH);
|
||||||
String fingerprint = uri.getUserInfo();
|
String fingerprint = uri.getUserInfo();
|
||||||
|
String host = uri.getHost().toLowerCase(Locale.ENGLISH);
|
||||||
if (scheme.equals("fdroidrepos") || scheme.equals("fdroidrepo")
|
if (scheme.equals("fdroidrepos") || scheme.equals("fdroidrepo")
|
||||||
|| scheme.equals("https") || scheme.equals("http")) {
|
|| scheme.equals("https") || scheme.equals("http")) {
|
||||||
String uriString = uri.toString().replace("fdroidrepo", "http").
|
// QRCode are more efficient in all upper case, so some incoming
|
||||||
replace(fingerprint + "@", "");
|
// URLs might be encoded in all upper case. Therefore, we allow
|
||||||
|
// the standard paths to be encoded all upper case, then they'll
|
||||||
|
// be forced to lower case. The scheme and host are downcased
|
||||||
|
// just to make them more readable in the dialog.
|
||||||
|
String uriString = uri.toString()
|
||||||
|
.replace(fingerprint + "@", "") // remove fingerprint
|
||||||
|
.replaceAll("/*$", "") // remove all trailing slashes
|
||||||
|
.replaceAll("/FDROID/REPO$", "/fdroid/repo")
|
||||||
|
.replaceAll("/FDROID/ARCHIVE$", "/fdroid/archive")
|
||||||
|
.replace(uri.getHost(), host) // downcase host name
|
||||||
|
.replace(intent.getScheme(), scheme) // downcase scheme
|
||||||
|
.replace("fdroidrepo", "http"); // make proper URL
|
||||||
showAddRepo(uriString, fingerprint);
|
showAddRepo(uriString, fingerprint);
|
||||||
Log.i("ManageRepo", uriString + " fingerprint: " + fingerprint);
|
Log.i("ManageRepo", uriString + " fingerprint: " + fingerprint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user