mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Revert "Perform additional URI validation in ShareRepository."
This reverts commit 04b7cb15cc.
This commit is contained in:
committed by
Cody Henthorne
parent
0b639e0169
commit
ba14031945
@@ -1,33 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class UriUtil {
|
||||
|
||||
/**
|
||||
* Ensures that an external URI is valid and doesn't contain any references to internal files or
|
||||
* any other trickiness.
|
||||
*/
|
||||
public static boolean isValidExternalUri(@NonNull Context context, @NonNull Uri uri) {
|
||||
if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
try {
|
||||
File file = new File(uri.getPath());
|
||||
|
||||
return file.getCanonicalPath().equals(file.getPath()) &&
|
||||
!file.getCanonicalPath().startsWith("/data") &&
|
||||
!file.getCanonicalPath().contains(context.getPackageName());
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user