mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-03 23:15:44 +01:00
Update isValidExternalUri.
This commit is contained in:
committed by
jeffrey-signal
parent
cd92feb2b7
commit
5310c19b99
@@ -15,7 +15,8 @@ object UriUtil {
|
||||
|
||||
/**
|
||||
* Ensures that an external URI is valid and doesn't contain any references to internal files or
|
||||
* any other trickiness.
|
||||
* any other trickiness. Rejects file:// URIs that reference internal storage, and content:// URIs
|
||||
* whose authority belongs to this application's own content providers.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isValidExternalUri(context: Context, uri: Uri): Boolean {
|
||||
@@ -29,6 +30,9 @@ object UriUtil {
|
||||
} catch (e: IOException) {
|
||||
return false
|
||||
}
|
||||
} else if (ContentResolver.SCHEME_CONTENT == uri.scheme) {
|
||||
val authority = uri.authority ?: return false
|
||||
return !authority.startsWith(context.packageName)
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user