From bf620cdfd61d0ba7fc6ad17f61dfd2414b73090e Mon Sep 17 00:00:00 2001 From: Ioan Moldovan Date: Mon, 18 Aug 2025 23:20:22 -0700 Subject: [PATCH 1/3] fix: duplicated signature after draft save --- .../Extensions/ComposeViewController+Nodes.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift index 708d1ca21..c254a3c29 100644 --- a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift +++ b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift @@ -160,8 +160,17 @@ 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() { + let body = mutableString.string.replacingOccurrences(of: "\r\n", with: "\n") + .replacingOccurrences(of: "\r", with: "\n") + .trimmingCharacters(in: .whitespacesAndNewlines) + let signature = signatureRaw.replacingOccurrences(of: "\r\n", with: "\n") + .replacingOccurrences(of: "\r", with: "\n") + .trimmingCharacters(in: .whitespacesAndNewlines) + let alreadyEndsWithSig = body.contains(signature) + if (!alreadyEndsWithSig) { + mutableString.append(signature.attributed(.regular(17))) + } } let height = max(decorator.frame(for: mutableString).height, 40) From 17b2d31a44f994537d66486705bfc3876ba7b4c3 Mon Sep 17 00:00:00 2001 From: Ioan <160680201+ioanatflowcrypt@users.noreply.github.com> Date: Tue, 19 Aug 2025 03:24:57 -0300 Subject: [PATCH 2/3] fixed signature raw --- .../Compose/Extensions/ComposeViewController+Nodes.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift index c254a3c29..edf406cba 100644 --- a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift +++ b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift @@ -169,7 +169,7 @@ extension ComposeViewController { .trimmingCharacters(in: .whitespacesAndNewlines) let alreadyEndsWithSig = body.contains(signature) if (!alreadyEndsWithSig) { - mutableString.append(signature.attributed(.regular(17))) + mutableString.append(signatureRaw.attributed(.regular(17))) } } From 7a71b6093db267a7e5020798711f04074937212b Mon Sep 17 00:00:00 2001 From: Ioan Moldovan Date: Sun, 7 Sep 2025 18:20:52 -0700 Subject: [PATCH 3/3] fix: pr reviews --- .../ComposeViewController+Nodes.swift | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift index edf406cba..5c5343b74 100644 --- a/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift +++ b/FlowCrypt/Controllers/Compose/Extensions/ComposeViewController+Nodes.swift @@ -161,14 +161,19 @@ extension ComposeViewController { } if let signatureRaw = getSignature() { - let body = mutableString.string.replacingOccurrences(of: "\r\n", with: "\n") - .replacingOccurrences(of: "\r", with: "\n") - .trimmingCharacters(in: .whitespacesAndNewlines) - let signature = signatureRaw.replacingOccurrences(of: "\r\n", with: "\n") - .replacingOccurrences(of: "\r", with: "\n") - .trimmingCharacters(in: .whitespacesAndNewlines) - let alreadyEndsWithSig = body.contains(signature) - if (!alreadyEndsWithSig) { + 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))) } }