Fix encoding issue

This commit is contained in:
Bob Sun 2017-04-26 23:01:42 -07:00
parent d94c7626a6
commit b3e7ed25cd
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 7 additions and 5 deletions

View file

@ -65,8 +65,9 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
} else {
plainText = "\(cellContents["password"]!)"
}
let name = URL(string: cellContents["name"]!)!.lastPathComponent
let url = URL(string: cellContents["name"]!)!.appendingPathExtension("gpg")
let encodedName = cellContents["name"]!.stringByAddingPercentEncodingForRFC3986()!
let name = URL(string: encodedName)!.lastPathComponent
let url = URL(string: encodedName)!.appendingPathExtension("gpg")
password = Password(name: name, url: url, plainText: plainText)
}
}

View file

@ -651,7 +651,7 @@ class PasswordStore {
try deleteDirectoryTree(at: passwordEntity.getURL()!)
try deletePasswordEntities(passwordEntity: passwordEntity)
try gitRm(path: deletedFileURL.path)
let _ = try gitCommit(message: "Remove \(deletedFileURL.deletingPathExtension()) from store using Pass for iOS.")
let _ = try gitCommit(message: "Remove \(deletedFileURL.deletingPathExtension().path.removingPercentEncoding!) from store using Pass for iOS.")
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
}
@ -663,7 +663,7 @@ class PasswordStore {
let saveURL = storeURL.appendingPathComponent(passwordEntity.getURL()!.path)
try self.encrypt(password: password).write(to: saveURL)
try gitAdd(path: passwordEntity.getURL()!.path)
let _ = try gitCommit(message: "Edit password for \(passwordEntity.getURL()!.deletingPathExtension().path) to store using Pass for iOS.")
let _ = try gitCommit(message: "Edit password for \(passwordEntity.getURL()!.deletingPathExtension().path.removingPercentEncoding!) to store using Pass for iOS.")
newPasswordEntity = passwordEntity
}
@ -680,7 +680,7 @@ class PasswordStore {
// delete
try deleteDirectoryTree(at: deletedFileURL)
try deletePasswordEntities(passwordEntity: passwordEntity)
let _ = try gitCommit(message: "Rename \(deletedFileURL.deletingPathExtension()) to \(password.url!.deletingPathExtension().path) using Pass for iOS.")
let _ = try gitCommit(message: "Rename \(deletedFileURL.deletingPathExtension().path.removingPercentEncoding!) to \(password.url!.deletingPathExtension().path.removingPercentEncoding!) using Pass for iOS.")
}
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
@ -689,6 +689,7 @@ class PasswordStore {
private func deletePasswordEntities(passwordEntity: PasswordEntity) throws {
var current: PasswordEntity? = passwordEntity
print(passwordEntity.path!)
while current != nil && (current!.children!.count == 0 || !current!.isDir) {
let parent = current!.parent
self.context.delete(current!)