From 8b935df7fb2e75130a37c7649a91ccbd64844204 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 7 Nov 2024 09:28:17 +0100 Subject: [PATCH 1/3] check folder path before upload Signed-off-by: alperozturk [skip ci] --- .../com/owncloud/android/ui/activity/FileDisplayActivity.java | 1 + .../com/owncloud/android/ui/activity/UploadFilesActivity.java | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 868513da42f2..29e5d5d3d33f 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -69,6 +69,7 @@ import com.nextcloud.utils.extensions.BundleExtensionsKt; import com.nextcloud.utils.extensions.FileExtensionsKt; import com.nextcloud.utils.extensions.IntentExtensionsKt; +import com.nextcloud.utils.fileNameValidator.FileNameValidator; import com.nextcloud.utils.view.FastScrollUtils; import com.owncloud.android.MainApp; import com.owncloud.android.R; diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index 01d93439542a..3b1f4935625a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -35,7 +35,6 @@ import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.nextcloud.utils.extensions.FileExtensionsKt; -import com.nextcloud.utils.fileNameValidator.FileNameValidator; import com.owncloud.android.R; import com.owncloud.android.databinding.UploadFilesLayoutBinding; import com.owncloud.android.lib.common.utils.Log_OC; @@ -60,7 +59,6 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.SearchView; import androidx.core.view.MenuItemCompat; From fa4a7898ef319dc6ebc093bca69b933a75aa54a4 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 11 Nov 2024 15:59:19 +0100 Subject: [PATCH 2/3] add missing changes Signed-off-by: alperozturk --- .../android/ui/activity/FileDisplayActivity.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 29e5d5d3d33f..f569a74fb0b7 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -35,7 +35,6 @@ import android.os.IBinder; import android.os.Looper; import android.os.Parcelable; -import android.provider.Settings; import android.text.TextUtils; import android.view.Menu; import android.view.MenuInflater; @@ -99,7 +98,6 @@ import com.owncloud.android.ui.asynctasks.FetchRemoteFileTask; import com.owncloud.android.ui.asynctasks.GetRemoteFileTask; import com.owncloud.android.ui.dialog.SendShareDialog; -import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment; import com.owncloud.android.ui.dialog.SortingOrderDialogFragment; import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment; import com.owncloud.android.ui.events.SearchEvent; @@ -159,7 +157,6 @@ import kotlin.Unit; import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; -import static com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment.SETUP_ENCRYPTION_DIALOG_TAG; import static com.owncloud.android.utils.PermissionUtil.PERMISSION_CHOICE_DIALOG_TAG; /** @@ -935,6 +932,12 @@ private void requestUploadOfFilesFromFileSystem(String localBasePath, String[] f default -> FileUploadWorker.LOCAL_BEHAVIOUR_FORGET; }; + boolean isValidFolderPath = FileNameValidator.INSTANCE.checkFolderPath(remotePathBase,getCapabilities(),this); + if (!isValidFolderPath) { + DisplayUtils.showSnackMessage(this, R.string.file_name_validator_error_contains_reserved_names_or_invalid_characters); + return; + } + FileUploadHelper.Companion.instance().uploadNewFiles(getUser().orElseThrow(RuntimeException::new), filePaths, decryptedRemotePaths, From e3807032b3bde3a5d1e8acd4dc182ee676fa32f0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 11 Nov 2024 16:00:55 +0100 Subject: [PATCH 3/3] add missing imports Signed-off-by: alperozturk --- .../com/owncloud/android/ui/activity/UploadFilesActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index 3b1f4935625a..01d93439542a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -35,6 +35,7 @@ import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.nextcloud.utils.extensions.FileExtensionsKt; +import com.nextcloud.utils.fileNameValidator.FileNameValidator; import com.owncloud.android.R; import com.owncloud.android.databinding.UploadFilesLayoutBinding; import com.owncloud.android.lib.common.utils.Log_OC; @@ -59,6 +60,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.SearchView; import androidx.core.view.MenuItemCompat;