From f2cf82ee8e626ccecb43f79be2ac29f498c99faf Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sat, 23 Oct 2021 15:58:07 +0200 Subject: [PATCH] Fix double quoting and missing new lines in message sent * Don't encode text inside code block * Make sure to replace \n with
in the html rendering. It's not respecting the common mark spec but this is the same behavior as Element --- src/actionshandler.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/actionshandler.cpp b/src/actionshandler.cpp index ae13f2e76..bee72970c 100644 --- a/src/actionshandler.cpp +++ b/src/actionshandler.cpp @@ -106,7 +106,20 @@ void ActionsHandler::postMessage(const QString &text, CustomEmojiModel *cem) { QString rawText = text; - QString cleanedText = text.toHtmlEscaped(); + auto stringList = text.split(QStringLiteral("```")); + QString cleanedText; + const auto count = stringList.count(); + for (int i = 0; i < count; i++) { + if (i % 2 == 0) { + if (i + 1 != count) { + cleanedText += stringList[i].toHtmlEscaped() + QStringLiteral("```"); + } else { + cleanedText += stringList[i].toHtmlEscaped(); + } + } else { + cleanedText += stringList[i] + QStringLiteral("```"); + } + } auto preprocess = [cem](const QString &it) -> QString { if (cem == nullptr) {