Use appendPath(...)
instead of appendEncodedPath(...)
.
I misread the documentation when first using the `appendEncodedPath` method, because it expects the path to already be encoded. This causes a bug because if you search for a '/'. The result is a malformed URI that has the path '/search//' instead of '/search/%2F'. Using `appendPath` will always encode the string given to it, which is desirable. Also check for empty strings, and return a URI that gives all apps. This was not strictly neccesary, because the code which invokes it checks for empty strings, but if somewhere else in the future starts to use this code, they would've had to know to check for empty strings first. Fixes #555.
This commit is contained in:
parent
46817b1893
commit
81b772c3fd
@ -304,9 +304,9 @@ public final class Utils {
|
||||
b.scheme(localRepoUri.getScheme().replaceFirst("http", "fdroidrepo"));
|
||||
b.appendQueryParameter("swap", "1");
|
||||
if (!TextUtils.isEmpty(FDroidApp.bssid)) {
|
||||
b.appendQueryParameter("bssid", Uri.encode(FDroidApp.bssid));
|
||||
b.appendQueryParameter("bssid", FDroidApp.bssid);
|
||||
if (!TextUtils.isEmpty(FDroidApp.ssid))
|
||||
b.appendQueryParameter("ssid", Uri.encode(FDroidApp.ssid));
|
||||
b.appendQueryParameter("ssid", FDroidApp.ssid);
|
||||
}
|
||||
return b.build();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
@ -542,17 +543,22 @@ public class AppProvider extends FDroidProvider {
|
||||
}
|
||||
|
||||
public static Uri getSearchUri(String query) {
|
||||
return getContentUri().buildUpon()
|
||||
.appendPath(PATH_SEARCH)
|
||||
.appendEncodedPath(query)
|
||||
.build();
|
||||
if (TextUtils.isEmpty(query)) {
|
||||
// Return all the things for an empty search.
|
||||
return getContentUri();
|
||||
} else {
|
||||
return getContentUri().buildUpon()
|
||||
.appendPath(PATH_SEARCH)
|
||||
.appendPath(query)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
public static Uri getSearchInstalledUri(String query) {
|
||||
return getContentUri()
|
||||
.buildUpon()
|
||||
.appendPath(PATH_SEARCH_INSTALLED)
|
||||
.appendEncodedPath(query)
|
||||
.appendPath(query)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -560,7 +566,7 @@ public class AppProvider extends FDroidProvider {
|
||||
return getContentUri()
|
||||
.buildUpon()
|
||||
.appendPath(PATH_SEARCH_CAN_UPDATE)
|
||||
.appendEncodedPath(query)
|
||||
.appendPath(query)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -568,7 +574,7 @@ public class AppProvider extends FDroidProvider {
|
||||
return getContentUri().buildUpon()
|
||||
.appendPath(PATH_SEARCH_REPO)
|
||||
.appendPath(repo.id + "")
|
||||
.appendEncodedPath(query)
|
||||
.appendPath(query)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user