Repository: thunderbird/thunderbird-android (language: kotlin)

Issue:
Recognize `--&nbsp;` as signature delimiter
### Checklist

- [X] I have used the search function to see if someone else has already submitted the same feature request.
- [X] I will describe the problem with as much detail as possible.
- [X] This issue only contains a request for one single feature, **not** multiple (related) features.

### App version

6.510

### Problem you are trying to solve

Get the nice signature separation functionality even when senders send questionable HTML emails.

Specifically, the Fastmail web interface currently makes it impossible to use a `-- ` separator and only allows setting a `--&nbsp;` separator. The GMail web interface correctly interprets those, but K-9 currently doesn't.

### Suggested solution

Also support `--&nbsp;` as signature delimiter for HTML emails

### Screenshots / Drawings / Technical details

_No response_


Discussion hints:
K-9 Mail currently doesn't try to detect signatures in HTML parts at all. So even if Fastmail were using `-- ` as separator, it wouldn't help.
It does at least strip them on replies (#6279 / https://github.com/thundernest/k-9/blob/main/app/core/src/test/java/com/fsck/k9/message/signature/HtmlSignatureRemoverTest.kt), right? Or is that currently not functional?
You're right. I was only thinking about displaying the message.

Pull request: Add support for signature delimiters using non-breaking space in HTML parts
Closes #6808

Test command: ./gradlew :app:core:testDebugUnitTest --tests "com.fsck.k9.message.signature.HtmlSignatureRemoverTest"

Fix patch:
diff --git a/app/core/src/main/java/com/fsck/k9/message/signature/HtmlSignatureRemover.kt b/app/core/src/main/java/com/fsck/k9/message/signature/HtmlSignatureRemover.kt
index 07746c20dcb..d7a0de6b472 100644
--- a/app/core/src/main/java/com/fsck/k9/message/signature/HtmlSignatureRemover.kt
+++ b/app/core/src/main/java/com/fsck/k9/message/signature/HtmlSignatureRemover.kt
@@ -130,7 +130,7 @@ class HtmlSignatureRemover {
     }
 
     companion object {
-        private val DASH_SIGNATURE_HTML = Pattern.compile("\\s*-- \\s*", Pattern.CASE_INSENSITIVE)
+        private val DASH_SIGNATURE_HTML = Pattern.compile("\\s*--[ \u00A0]\\s*")
         private val BLOCKQUOTE = Tag.valueOf("blockquote")
         private val BR = Tag.valueOf("br")
 


Test patch:
diff --git a/app/core/src/test/java/com/fsck/k9/message/signature/HtmlSignatureRemoverTest.kt b/app/core/src/test/java/com/fsck/k9/message/signature/HtmlSignatureRemoverTest.kt
index a8c79c7758e..932f192ae85 100644
--- a/app/core/src/test/java/com/fsck/k9/message/signature/HtmlSignatureRemoverTest.kt
+++ b/app/core/src/test/java/com/fsck/k9/message/signature/HtmlSignatureRemoverTest.kt
@@ -182,4 +182,22 @@ class HtmlSignatureRemoverTest {
             """.trimIndent().removeNewlines(),
         )
     }
+
+    @Test
+    fun `signature delimiter with non-breaking space character entity`() {
+        val html = "Body text<br>--&nbsp;<br>Signature text"
+
+        val withoutSignature = stripSignature(html)
+
+        assertThat(extractText(withoutSignature)).isEqualTo("Body text")
+    }
+
+    @Test
+    fun `signature delimiter with non-breaking space`() {
+        val html = "Body text<br>--\u00A0<br>Signature text"
+
+        val withoutSignature = stripSignature(html)
+
+        assertThat(extractText(withoutSignature)).isEqualTo("Body text")
+    }
 }