mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-31 17:04:59 +01:00
Improved stability of ShareProvider while querying file
Credit: Julien Thomas (https://twitter.com/julien_thomas) - Protektoid Project (https://protektoid.com)
This commit is contained in:
parent
b26c106781
commit
330b78b301
@ -69,11 +69,14 @@ public class ShareProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private File getFile(@NonNull Uri uri) throws FileNotFoundException {
|
||||
final Context context = getContext();
|
||||
if (context == null) throw new IllegalStateException();
|
||||
final String lastPathSegment = uri.getLastPathSegment();
|
||||
if (lastPathSegment == null) throw new FileNotFoundException(uri.toString());
|
||||
File filesDir = getFilesDir(getContext());
|
||||
File filesDir = getFilesDir(context);
|
||||
if (filesDir == null) throw new FileNotFoundException(uri.toString());
|
||||
try {
|
||||
filesDir = filesDir.getCanonicalFile();
|
||||
File file = new File(filesDir, lastPathSegment).getCanonicalFile();
|
||||
if (!FilesKt.startsWith(file, filesDir)) throw new SecurityException(uri.toString());
|
||||
return file;
|
||||
|
Loading…
x
Reference in New Issue
Block a user