From 718fb681c3ef9996498ed054ddad8860431bfd21 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 3 Nov 2022 17:17:21 +0000 Subject: [PATCH] replacing & html entity with & --- .../matrix/sync/internal/sync/message/RichMessageParser.kt | 2 +- .../st/matrix/sync/internal/sync/RichMessageParserTest.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/RichMessageParser.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/RichMessageParser.kt index 1506c86..97960b2 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/RichMessageParser.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/RichMessageParser.kt @@ -56,7 +56,7 @@ class RichMessageParser { } -private fun String.removeHtmlEntities() = this.replace(""", "\"").replace("'", "'").replace("'", "'") +private fun String.removeHtmlEntities() = this.replace(""", "\"").replace("'", "'").replace("'", "'").replace("&", "&") private fun String.dropTextFallback() = this.lines() .dropWhile { it.startsWith("> ") || it.isEmpty() } diff --git a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt index 69622d4..796dcfd 100644 --- a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt +++ b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt @@ -36,6 +36,12 @@ class RichMessageParserTest { expected = RichText(listOf(Normal("Hello world! \"foo bar\""))) ) + @Test + fun `replaces ampersand entity`() = runParserTest( + input = "Hello & world!", + expected = RichText(listOf(Normal("Hello & world!"))) + ) + @Test fun `replaces apostrophe entity`() = runParserTest( Case(