Skip to content

Fix folder naming not using capabilities renamer #3566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion iOSClient/Extensions/UIAlertController+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ extension UIAlertController {
textField.autocapitalizationType = .words
}

// only allow saving if folder name exists
NotificationCenter.default.addObserver(
forName: UITextField.textDidChangeNotification,
object: alertController.textFields?.first,
Expand Down
5 changes: 0 additions & 5 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,6 @@ final class NCGlobal: Sendable {
//
let defaultSnapshotConfiguration = "DefaultPreviewConfiguration"

// FORBIDDEN CHARACTERS
//
// TODO: Remove this
let forbiddenCharacters = ["/", "\\", ":", "\"", "|", "?", "*", "<", ">"]

// DIAGNOSTICS CLIENTS
//
let diagnosticIssueSyncConflicts = "sync_conflicts"
Expand Down
8 changes: 2 additions & 6 deletions iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ class NCNetworkingE2EECreateFolder: NSObject {
let global = NCGlobal.shared

func createFolder(fileName: String, serverUrl: String, sceneIdentifier: String?, session: NCSession.Session) async -> NKError {
var fileNameFolder = utility.removeForbiddenCharacters(fileName)
if fileName != fileNameFolder {
let errorDescription = String(format: NSLocalizedString("_forbidden_characters_", comment: ""), global.forbiddenCharacters.joined(separator: " "))
let error = NKError(errorCode: global.errorConflict, errorDescription: errorDescription)
return error
}
var fileNameFolder = FileAutoRenamer.rename(fileName, isFolderPath: true, account: session.account)

let fileNameIdentifier = networkingE2EE.generateRandomIdentifier()
let serverUrlFileName = serverUrl + "/" + fileNameIdentifier
fileNameFolder = utilityFileSystem.createFileName(fileNameFolder, serverUrl: serverUrl, account: session.account)
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Networking/NCNetworking+WebDAV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ extension NCNetworking {
selector: String? = nil,
options: NKRequestOptions = NKRequestOptions()) async -> (serverExists: Bool, error: NKError) {

var fileNameFolder = utility.removeForbiddenCharacters(fileName.trimmingCharacters(in: .whitespacesAndNewlines))
var fileNameFolder = FileAutoRenamer.rename(fileName, isFolderPath: true, account: session.account)
if !overwrite {
fileNameFolder = utilityFileSystem.createFileName(fileNameFolder, serverUrl: serverUrl, account: session.account)
}
Expand Down
9 changes: 2 additions & 7 deletions iOSClient/Settings/Advanced/File Name/NCFileNameModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ class NCFileNameModel: ObservableObject, ViewOnAppearHandling {

/// Submits the changed file name.
func submitChangedName() {
let fileNameWithoutForbiddenChars = NCUtility().removeForbiddenCharacters(changedName)
if changedName != fileNameWithoutForbiddenChars {
changedName = fileNameWithoutForbiddenChars
let errorDescription = String(format: NSLocalizedString("_forbidden_characters_", comment: ""), NCGlobal.shared.forbiddenCharacters.joined(separator: " "))
let error = NKError(errorCode: NCGlobal.shared.errorConflict, errorDescription: errorDescription)
NCContentPresenter().showInfo(error: error)
}
changedName = FileAutoRenamer.rename(changedName, account: session.account)

}

/// Generates a preview file name based on current settings and file name mask.
Expand Down
8 changes: 0 additions & 8 deletions iOSClient/Utility/NCUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ final class NCUtility: NSObject, Sendable {
return (usedmegabytes, totalmegabytes)
}

func removeForbiddenCharacters(_ fileName: String) -> String {
var fileName = fileName
for character in global.forbiddenCharacters {
fileName = fileName.replacingOccurrences(of: character, with: "")
}
return fileName
}

func getHeightHeaderEmptyData(view: UIView, portraitOffset: CGFloat, landscapeOffset: CGFloat) -> CGFloat {
var height: CGFloat = 0
if UIDevice.current.orientation.isPortrait {
Expand Down
Loading