Check file name not path in uri uploader

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-09-23 17:05:55 +02:00
parent 4ecdf797db
commit 08024d54d5
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

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