Skip to content

Commit

Permalink
Merge pull request #13996 from nextcloud/backport/13972/stable-3.30
Browse files Browse the repository at this point in the history
[stable-3.30] BugFix - Check Folder Path Before Upload
  • Loading branch information
tobiasKaminsky authored Nov 12, 2024
2 parents f3b4aae + e380703 commit 87bbb11
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,6 +68,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;
Expand Down Expand Up @@ -98,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;
Expand Down Expand Up @@ -158,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;

/**
Expand Down Expand Up @@ -934,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,
Expand Down

0 comments on commit 87bbb11

Please sign in to comment.