From 1ea2a05ccced2932c5bd4e31b52094e9c2677b54 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 7 Jan 2025 08:32:51 +0100 Subject: [PATCH] Removed file provider workaround to fix security issue Refs CanHub/Android-Image-Cropper#644 --- .../main/kotlin/com/canhub/cropper/BitmapUtils.kt | 14 ++------------ .../kotlin/com/canhub/cropper/CropFileProvider.kt | 5 +++-- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/cropper/src/main/kotlin/com/canhub/cropper/BitmapUtils.kt b/cropper/src/main/kotlin/com/canhub/cropper/BitmapUtils.kt index 6e1b7b51..548efb5f 100644 --- a/cropper/src/main/kotlin/com/canhub/cropper/BitmapUtils.kt +++ b/cropper/src/main/kotlin/com/canhub/cropper/BitmapUtils.kt @@ -457,18 +457,8 @@ internal object BitmapUtils { } // We have this because of a HUAWEI path bug when we use getUriForFile if (SDK_INT >= 29) { - try { - val file = File.createTempFile( - "cropped", - ext, - context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), - ) - getUriForFile(context, file) - } catch (e: Exception) { - Log.e("AIC", "${e.message}") - val file = File.createTempFile("cropped", ext, context.cacheDir) - getUriForFile(context, file) - } + val file = File.createTempFile("cropped", ext, context.cacheDir) + getUriForFile(context, file) } else { Uri.fromFile(File.createTempFile("cropped", ext, context.cacheDir)) } diff --git a/cropper/src/main/kotlin/com/canhub/cropper/CropFileProvider.kt b/cropper/src/main/kotlin/com/canhub/cropper/CropFileProvider.kt index f366a48d..cdae4953 100644 --- a/cropper/src/main/kotlin/com/canhub/cropper/CropFileProvider.kt +++ b/cropper/src/main/kotlin/com/canhub/cropper/CropFileProvider.kt @@ -7,6 +7,7 @@ import androidx.core.content.FileProvider * * See https://developer.android.com/guide/topics/manifest/provider-element.html for details. */ -class CropFileProvider : FileProvider() { - // This class intentionally left blank. +class CropFileProvider() : FileProvider(R.xml.library_file_paths) { + // This class intentionally left blank. + // https://android-review.googlesource.com/c/platform/frameworks/support/+/1978527 }