From 66f4eeb6ad4bf59fe18e27e23aa669652c441898 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 6 Dec 2020 22:34:02 +0100 Subject: [PATCH] Implemented catching exceptions in removeSensitiveDataFromMessage() --- .../dankito/banking/fints/log/MessageLogCollector.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt index 5ad69a71..3a658972 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt @@ -23,7 +23,7 @@ open class MessageLogCollector { // in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData open val messageLogWithoutSensitiveData: List - get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) } + get() = messageLog.map { MessageLogEntry(safelyRemoveSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) } open fun addMessageLog(message: String, type: MessageLogEntryType, bank: BankData) { @@ -56,6 +56,14 @@ open class MessageLogCollector { } + protected open fun safelyRemoveSensitiveDataFromMessage(message: String, bank: BankData?): String { + try { + return removeSensitiveDataFromMessage(message, bank) + } catch (e: Exception) { + return "! WARNING !\r\nCould not remove sensitive data!\r\n$e\r\n$message" + } + } + protected open fun removeSensitiveDataFromMessage(message: String, bank: BankData?): String { if (bank == null) { return message