Fix #340: Always end password entries with a newline
This commit is contained in:
parent
283a32f6cd
commit
b60ce3b003
4 changed files with 15 additions and 13 deletions
|
|
@ -49,11 +49,6 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
|
||||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||||
super.prepare(for: segue, sender: sender)
|
super.prepare(for: segue, sender: sender)
|
||||||
if segue.identifier == "saveAddPasswordSegue" {
|
if segue.identifier == "saveAddPasswordSegue" {
|
||||||
var plainText = (fillPasswordCell?.getContent())!
|
|
||||||
if let additionsString = additionsCell?.getContent(), additionsString.isEmpty == false {
|
|
||||||
plainText.append("\n")
|
|
||||||
plainText.append(additionsString)
|
|
||||||
}
|
|
||||||
let (name, url) = getNameURL()
|
let (name, url) = getNameURL()
|
||||||
password = Password(name: name, url: url, plainText: plainText)
|
password = Password(name: name, url: url, plainText: plainText)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,10 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
|
||||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||||
super.prepare(for: segue, sender: sender)
|
super.prepare(for: segue, sender: sender)
|
||||||
if segue.identifier == "saveEditPasswordSegue" {
|
if segue.identifier == "saveEditPasswordSegue" {
|
||||||
var plainText = (fillPasswordCell?.getContent())!
|
let editedPlainText = plainText
|
||||||
if let additionsString = additionsCell?.getContent(), additionsString.isEmpty == false {
|
|
||||||
plainText.append("\n")
|
|
||||||
plainText.append(additionsString)
|
|
||||||
}
|
|
||||||
let (name, url) = getNameURL()
|
let (name, url) = getNameURL()
|
||||||
if password!.plainText != plainText || password!.url.path != url.path {
|
if password!.plainText != editedPlainText || password!.url.path != url.path {
|
||||||
password!.updatePassword(name: name, url: url, plainText: plainText)
|
password!.updatePassword(name: name, url: url, plainText: editedPlainText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,18 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
private var scanQRCodeCell: UITableViewCell?
|
private var scanQRCodeCell: UITableViewCell?
|
||||||
private var memorablePasswordGeneratorCell: UITableViewCell?
|
private var memorablePasswordGeneratorCell: UITableViewCell?
|
||||||
|
|
||||||
|
var plainText: String {
|
||||||
|
var plainText = (fillPasswordCell?.getContent())!
|
||||||
|
if let additionsString = additionsCell?.getContent(), !additionsString.isEmpty {
|
||||||
|
plainText.append("\n")
|
||||||
|
plainText.append(additionsString)
|
||||||
|
}
|
||||||
|
if !plainText.trimmingCharacters(in: .whitespaces).hasSuffix("\n") {
|
||||||
|
plainText.append("\n")
|
||||||
|
}
|
||||||
|
return plainText
|
||||||
|
}
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ public class Password {
|
||||||
initEverything()
|
initEverything()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public func updatePassword(name: String, url: URL, plainText: String) {
|
public func updatePassword(name: String, url: URL, plainText: String) {
|
||||||
guard self.plainText != plainText || self.url != url else {
|
guard self.plainText != plainText || self.url != url else {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue