Prevent edits from removing quotes at the beginning of a message

This commit is contained in:
Nicolas Werner 2021-11-13 03:20:46 +01:00
parent b0530089ab
commit 38e3498978
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -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();