Add more password name checks.

This commit is contained in:
Yishi Lin 2017-10-15 21:37:00 +08:00
parent 49180d74e6
commit b9ef596bfb
5 changed files with 56 additions and 16 deletions

View file

@ -603,12 +603,19 @@ public class PasswordStore {
}
var passwordURL = password.url!
var previousURLLength = 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 {
throw AppError.WrongPasswordFilename
}
previousURLLength = passwordURL.absoluteString.count
}
paths.reverse()
print(paths)
var parentPasswordEntity: PasswordEntity? = nil
for path in paths {
let isDir = !path.hasSuffix(".gpg")