mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-04 07:25:25 +01:00
Add null check in UriUtil.
This commit is contained in:
committed by
jeffrey-signal
parent
5db8463c70
commit
98d9b12438
@@ -9,7 +9,6 @@ import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
object UriUtil {
|
||||
|
||||
@@ -22,12 +21,13 @@ object UriUtil {
|
||||
fun isValidExternalUri(context: Context, uri: Uri): Boolean {
|
||||
if (ContentResolver.SCHEME_FILE == uri.scheme) {
|
||||
try {
|
||||
val file = File(uri.path)
|
||||
val path = uri.path ?: return false
|
||||
val file = File(path)
|
||||
|
||||
return file.canonicalPath == file.path &&
|
||||
!file.canonicalPath.startsWith("/data") &&
|
||||
!file.canonicalPath.contains(context.packageName)
|
||||
} catch (e: IOException) {
|
||||
} catch (e: Exception) {
|
||||
return false
|
||||
}
|
||||
} else if (ContentResolver.SCHEME_CONTENT == uri.scheme) {
|
||||
|
||||
Reference in New Issue
Block a user