diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index e733324..7ed2ed6 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -290,14 +290,14 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl } // check whether we can parse the filename (be consistent with PasswordStore::addPasswordEntities) - var previousURLLength = Int.max + var previousPathLength = Int.max while passwordURL.path != "." { passwordURL = passwordURL.deletingLastPathComponent() - if passwordURL.absoluteString.count >= previousURLLength { + if passwordURL.path != "." && passwordURL.path.count >= previousPathLength { Utils.alert(title: "Cannot Save", message: "Cannot parse the filename. Please check and simplify the password name.", controller: self, completion: nil) return false } - previousURLLength = passwordURL.absoluteString.count + previousPathLength = passwordURL.path.count } return true diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 5b98c0e..37e2718 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -592,16 +592,16 @@ public class PasswordStore { } var passwordURL = password.url! - var previousURLLength = Int.max + var previousPathLength = Int.max var paths: [String] = [] while passwordURL.path != "." { paths.append(passwordURL.path) passwordURL = passwordURL.deletingLastPathComponent() // better identify errors before saving a new password - if passwordURL.absoluteString.count >= previousURLLength { + if passwordURL.path != "." && passwordURL.path.count >= previousPathLength { throw AppError.WrongPasswordFilename } - previousURLLength = passwordURL.absoluteString.count + previousPathLength = passwordURL.path.count } paths.reverse() print(paths)