Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit ccea632a authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #6811 from thundernest/signature_remover_nbsp

Add support for signature delimiters using non-breaking space in HTML parts
parents 590ab791 e621d3f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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")

+18 −0
Original line number Diff line number Diff line
@@ -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")
    }
}