Merge pull request #13606 from nextcloud/bugfix/check-file-name-not-path-in-uri-uploader

BugFix - Check Filename in UriUploader
This commit is contained in:
Alper Öztürk 2024-09-24 09:04:56 +02:00 committed by GitHub
commit d4ea700b1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,7 @@ import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask
import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener
import com.owncloud.android.ui.fragment.TaskRetainerFragment
import com.owncloud.android.utils.UriUtils.getDisplayNameForUri
import java.io.File
/**
* This class examines URIs pointing to files to upload and then requests [FileUploadHelper] to upload them.
@ -79,9 +80,12 @@ class UriUploader(
.filterNotNull()
.map { it as Uri }
.map { Pair(it, getRemotePathForUri(it)) }
.filter { (_, filename) ->
.filter { (_, path) ->
val file = File(path)
val filename = file.name
isFilenameValid = FileNameValidator.checkFileName(
filename.removePrefix("/"),
filename,
mActivity.capabilities,
mActivity,
null