Fix a bug in file name checking
This commit is contained in:
parent
9879cef654
commit
54bd42d2fb
2 changed files with 6 additions and 6 deletions
|
|
@ -290,14 +290,14 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
}
|
}
|
||||||
|
|
||||||
// check whether we can parse the filename (be consistent with PasswordStore::addPasswordEntities)
|
// check whether we can parse the filename (be consistent with PasswordStore::addPasswordEntities)
|
||||||
var previousURLLength = Int.max
|
var previousPathLength = Int.max
|
||||||
while passwordURL.path != "." {
|
while passwordURL.path != "." {
|
||||||
passwordURL = passwordURL.deletingLastPathComponent()
|
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)
|
Utils.alert(title: "Cannot Save", message: "Cannot parse the filename. Please check and simplify the password name.", controller: self, completion: nil)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
previousURLLength = passwordURL.absoluteString.count
|
previousPathLength = passwordURL.path.count
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -592,16 +592,16 @@ public class PasswordStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
var passwordURL = password.url!
|
var passwordURL = password.url!
|
||||||
var previousURLLength = Int.max
|
var previousPathLength = Int.max
|
||||||
var paths: [String] = []
|
var paths: [String] = []
|
||||||
while passwordURL.path != "." {
|
while passwordURL.path != "." {
|
||||||
paths.append(passwordURL.path)
|
paths.append(passwordURL.path)
|
||||||
passwordURL = passwordURL.deletingLastPathComponent()
|
passwordURL = passwordURL.deletingLastPathComponent()
|
||||||
// better identify errors before saving a new password
|
// better identify errors before saving a new password
|
||||||
if passwordURL.absoluteString.count >= previousURLLength {
|
if passwordURL.path != "." && passwordURL.path.count >= previousPathLength {
|
||||||
throw AppError.WrongPasswordFilename
|
throw AppError.WrongPasswordFilename
|
||||||
}
|
}
|
||||||
previousURLLength = passwordURL.absoluteString.count
|
previousPathLength = passwordURL.path.count
|
||||||
}
|
}
|
||||||
paths.reverse()
|
paths.reverse()
|
||||||
print(paths)
|
print(paths)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue