Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URI passed to ContentProvider #803

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class MediaItemContentProvider : ContentProvider() {
private lateinit var memoryCache : LruCache<String, ByteArray>

override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {
if (uri.fragment != null) {
if (uri.encodedFragment != null) {
// we store the original scheme://host in fragment since it should be unused
val origin = Uri.parse(uri.fragment)
val fixedUri = uri.buildUpon().fragment(null).scheme(origin.scheme).authority(origin.authority).toString()
val origin = Uri.parse(uri.encodedFragment)
val fixedUri = uri.buildUpon().fragment(null).scheme(origin.scheme).encodedAuthority(origin.encodedAuthority).toString()

// check if we already cached the image
val bytes = memoryCache.get(fixedUri)
Expand Down
2 changes: 1 addition & 1 deletion lib/services/queue_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ class QueueService {
artUri = Uri(scheme: "content", host: contentProviderPackageName, path: path_helper.join(applicationSupportDirectory.absolute.path, Assets.images.albumWhite.path));
} else {
// store the origin in fragment since it should be unused
artUri = artUri.replace(scheme: "content", host: contentProviderPackageName, fragment: ["http", "https"].contains(artUri.scheme) ? artUri.origin : null);
artUri = Uri(scheme: "content", host: contentProviderPackageName, path: artUri.path, fragment: ["http", "https"].contains(artUri.scheme) ? artUri.origin : null);
}
}

Expand Down