Fix a bug in file name checking

This commit is contained in:
Yishi Lin 2017-10-16 04:14:11 +08:00
parent 9879cef654
commit 54bd42d2fb
2 changed files with 6 additions and 6 deletions

View file

@ -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