|
@@ -112,9 +112,15 @@ object FileUtils {
|
|
}
|
|
}
|
|
|
|
|
|
@Suppress("NestedBlockDepth")
|
|
@Suppress("NestedBlockDepth")
|
|
- fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File {
|
|
|
|
|
|
+ fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File? {
|
|
val cachedFile = File(context.cacheDir, filename)
|
|
val cachedFile = File(context.cacheDir, filename)
|
|
|
|
|
|
|
|
+ if (!cachedFile.canonicalPath.startsWith(context.cacheDir.canonicalPath, true)) {
|
|
|
|
+ Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
|
|
|
+ cachedFile.delete()
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
|
|
+
|
|
if (cachedFile.exists()) {
|
|
if (cachedFile.exists()) {
|
|
Log.d(TAG, "file is already in cache")
|
|
Log.d(TAG, "file is already in cache")
|
|
} else {
|
|
} else {
|