From 38e349897812cdce409fd8c0faea205a3fb862c0 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 13 Nov 2021 03:20:46 +0100 Subject: [PATCH] Prevent edits from removing quotes at the beginning of a message --- src/Utils.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index b0fb01b1..b838a971 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -59,11 +59,14 @@ std::string utils::stripReplyFromBody(const std::string &bodyi) { QString body = QString::fromStdString(bodyi); - QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption); - while (body.startsWith(">")) - body.remove(plainQuote); - if (body.startsWith("\n")) - body.remove(0, 1); + if (body.startsWith("> <")) { + auto segments = body.split('\n'); + while (!segments.isEmpty() && segments.begin()->startsWith('>')) + segments.erase(segments.begin()); + if (!segments.empty() && segments.first().isEmpty()) + segments.erase(segments.begin()); + body = segments.join('\n'); + } body.replace("@room", QString::fromUtf8("@\u2060room")); return body.toStdString();