From 138506211ac7e7df26b0192e737b8c3e6e048988 Mon Sep 17 00:00:00 2001 From: Ean Lombardo Date: Thu, 5 Sep 2024 08:19:08 -0700 Subject: [PATCH] Check that a string contains markdown symbols instead of matches (#2080) .* does not match line breaks, so this regex would never apply to multiline text. This checks for contains instead of using .* to account for this. Fixes #2049 --- .../com/habitrpg/common/habitica/helpers/MarkdownParser.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/habitrpg/common/habitica/helpers/MarkdownParser.kt b/common/src/main/java/com/habitrpg/common/habitica/helpers/MarkdownParser.kt index fe4acac40..4d8b97158 100644 --- a/common/src/main/java/com/habitrpg/common/habitica/helpers/MarkdownParser.kt +++ b/common/src/main/java/com/habitrpg/common/habitica/helpers/MarkdownParser.kt @@ -204,12 +204,12 @@ object MarkdownParser { return EmojiParser.convertToCheatCode(input.toString()) } - private val markdownRegex = ".*[*#_\\[`~].*".toRegex() + private val markdownRegex = "[*#_\\[`~]".toRegex() private val imageMarkdownRegex = """!\[.*?]\(.*?".*?"\)""".toRegex() private val markdownLinkRegex = "\\[([^\\]]+)\\]\\(([^\\)]+)\\)".toRegex() fun containsMarkdown(text: String): Boolean { - return text.matches(markdownRegex) || + return text.contains(markdownRegex) || text.contains(imageMarkdownRegex) || text.contains(markdownLinkRegex) }