Use UriUtil when checking if a URI is a file.
UriUtil.isFileUri contains several additional fixes, so this ensure that existing instances where we check for the file scheme use this method as well. This covers all existing instances in the app of SCHEME_FILE. Change-Id: I1f3131b33823eae3e620aa9608be8e72b2e84aa2 Bug: 215212561
This commit is contained in:
@@ -52,6 +52,7 @@ import com.android.messaging.util.Assert;
|
|||||||
import com.android.messaging.util.ContentType;
|
import com.android.messaging.util.ContentType;
|
||||||
import com.android.messaging.util.LogUtil;
|
import com.android.messaging.util.LogUtil;
|
||||||
import com.android.messaging.util.OsUtil;
|
import com.android.messaging.util.OsUtil;
|
||||||
|
import com.android.messaging.util.UriUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -1018,8 +1019,7 @@ public class PduPersister {
|
|||||||
String path = null;
|
String path = null;
|
||||||
if (null != uri) {
|
if (null != uri) {
|
||||||
final String scheme = uri.getScheme();
|
final String scheme = uri.getScheme();
|
||||||
if (null == scheme || scheme.equals("") ||
|
if (null == scheme || scheme.equals("") || UriUtil.isFileUri(uri)) {
|
||||||
scheme.equals(ContentResolver.SCHEME_FILE)) {
|
|
||||||
path = uri.getPath();
|
path = uri.getPath();
|
||||||
|
|
||||||
} else if (scheme.equals("http")) {
|
} else if (scheme.equals("http")) {
|
||||||
|
|||||||
@@ -117,15 +117,11 @@ public class FileUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isFileUri(final Uri uri) {
|
|
||||||
return TextUtils.equals(uri.getScheme(), ContentResolver.SCHEME_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks if the file is in /data, and don't allow any app to send personal information.
|
// Checks if the file is in /data, and don't allow any app to send personal information.
|
||||||
// We're told it's possible to create world readable hardlinks to other apps private data
|
// We're told it's possible to create world readable hardlinks to other apps private data
|
||||||
// so we ban all /data file uris.
|
// so we ban all /data file uris.
|
||||||
public static boolean isInPrivateDir(Uri uri) {
|
public static boolean isInPrivateDir(Uri uri) {
|
||||||
if (!isFileUri(uri)) {
|
if (!UriUtil.isFileUri(uri)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final File file = new File(uri.getPath());
|
final File file = new File(uri.getPath());
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ public class ImageUtils {
|
|||||||
if (MediaScratchFileProvider.isMediaScratchSpaceUri(mUri)) {
|
if (MediaScratchFileProvider.isMediaScratchSpaceUri(mUri)) {
|
||||||
inputFilePath = MediaScratchFileProvider.getFileFromUri(mUri).getAbsolutePath();
|
inputFilePath = MediaScratchFileProvider.getFileFromUri(mUri).getAbsolutePath();
|
||||||
} else {
|
} else {
|
||||||
if (!TextUtils.equals(mUri.getScheme(), ContentResolver.SCHEME_FILE)) {
|
if (!UriUtil.isFileUri(mUri)) {
|
||||||
Assert.fail("Expected a GIF file uri, but actual uri = " + mUri.toString());
|
Assert.fail("Expected a GIF file uri, but actual uri = " + mUri.toString());
|
||||||
}
|
}
|
||||||
inputFilePath = mUri.getPath();
|
inputFilePath = mUri.getPath();
|
||||||
|
|||||||
Reference in New Issue
Block a user