Implemented parsing TAN challenge's HTML
This commit is contained in:
parent
8033399fd7
commit
b53eecd78e
|
@ -41,6 +41,25 @@ extension String {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Be aware that this crashes when used in a View's body method. So use it only e.g. in init() method
|
||||||
|
///
|
||||||
|
/// This an htmlToString has been copied from https://stackoverflow.com/a/47230632
|
||||||
|
///
|
||||||
|
var htmlToAttributedString: NSAttributedString? {
|
||||||
|
guard let data = data(using: .utf8) else { return nil }
|
||||||
|
do {
|
||||||
|
return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
|
||||||
|
} catch {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var htmlToString: String {
|
||||||
|
return htmlToAttributedString?.string ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var isCoreDataId: Bool {
|
var isCoreDataId: Bool {
|
||||||
return self.starts(with: "x-coredata://")
|
return self.starts(with: "x-coredata://")
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ struct EnterTanDialog: View {
|
||||||
|
|
||||||
private let imageTanChallenge: ImageTanChallenge?
|
private let imageTanChallenge: ImageTanChallenge?
|
||||||
|
|
||||||
|
private let messageToShowToUser: String
|
||||||
|
|
||||||
@State private var enteredTan = ""
|
@State private var enteredTan = ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +59,8 @@ struct EnterTanDialog: View {
|
||||||
self.flickerCodeTanChallenge = tanChallenge as? FlickerCodeTanChallenge
|
self.flickerCodeTanChallenge = tanChallenge as? FlickerCodeTanChallenge
|
||||||
self.imageTanChallenge = tanChallenge as? ImageTanChallenge
|
self.imageTanChallenge = tanChallenge as? ImageTanChallenge
|
||||||
|
|
||||||
|
self.messageToShowToUser = tanChallenge.messageToShowToUser.htmlToString // parse in init() calling this method in body { } crashes application
|
||||||
|
|
||||||
if let decodingError = (tanChallenge as? FlickerCodeTanChallenge)?.flickerCode.decodingError {
|
if let decodingError = (tanChallenge as? FlickerCodeTanChallenge)?.flickerCode.decodingError {
|
||||||
showDecodingTanChallengeFailedErrorDelayed(decodingError)
|
showDecodingTanChallengeFailedErrorDelayed(decodingError)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +101,7 @@ struct EnterTanDialog: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
CollapsibleText(tanChallenge.messageToShowToUser)
|
CollapsibleText(messageToShowToUser)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(.top, 6)
|
.padding(.top, 6)
|
||||||
|
|
Loading…
Reference in New Issue