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

Removed file provider workaround to fix security issue #659

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion cropper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/library_file_paths"/>
android:resource="@xml/cropper_library_file_paths"/>
</provider>
<activity
android:name="com.canhub.cropper.CropImageActivity"
Expand Down
14 changes: 2 additions & 12 deletions cropper/src/main/kotlin/com/canhub/cropper/BitmapUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.cropper_library_file_paths) {
// This class intentionally left blank.
// https://android-review.googlesource.com/c/platform/frameworks/support/+/1978527
}
Loading