diff --git a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift index 708d1ca21..5c5343b74 100644 --- a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift +++ b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift @@ -160,8 +160,22 @@ extension ComposeViewController { mutableString.append(styledQuote) } - if let signature = getSignature(), !mutableString.string.replacingOccurrences(of: "\r", with: "").contains(signature) { - mutableString.append(signature.attributed(.regular(17))) + if let signatureRaw = getSignature() { + func normalize(_ s: String) -> String { + return s + .replacingOccurrences(of: "\r\n", with: "\n") + .replacingOccurrences(of: "\r", with: "\n") + // fix html signature duplicate issue + // https://github.com/FlowCrypt/flowcrypt-ios/pull/2684#discussion_r2318361291 + .replacingOccurrences(of: "\u{00A0}", with: " ") + .trimmingCharacters(in: .whitespacesAndNewlines) + } + let body = normalize(mutableString.string) + let signature = normalize(signatureRaw) + let alreadyHasSig = body.contains(signature) + if !alreadyHasSig { + mutableString.append(signatureRaw.attributed(.regular(17))) + } } let height = max(decorator.frame(for: mutableString).height, 40)