mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
detekt
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
18e0ae31bc
commit
ea7d48fb67
1 changed files with 12 additions and 1 deletions
|
@ -30,6 +30,7 @@ import android.content.ContentResolver
|
|||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.OpenableColumns
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
|
@ -115,7 +116,17 @@ object FileUtils {
|
|||
fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File? {
|
||||
val cachedFile = File(context.cacheDir, filename)
|
||||
|
||||
if (!cachedFile.canonicalPath.startsWith(context.cacheDir.canonicalPath, true)) {
|
||||
val aboveOrEqualAPI26Check =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
|
||||
|
||||
val belowAPI26Check =
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O &&
|
||||
!cachedFile.canonicalPath.startsWith(context.cacheDir.canonicalPath, true)
|
||||
|
||||
val isOutsideCacheDir = aboveOrEqualAPI26Check || belowAPI26Check
|
||||
|
||||
if (isOutsideCacheDir) {
|
||||
Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
||||
cachedFile.delete()
|
||||
return null
|
||||
|
|
Loading…
Reference in a new issue