Cleanup @room escape logic a bit

This commit is contained in:
Nicolas Werner 2021-08-19 18:26:05 +02:00
parent c853dd3593
commit b63289ba54
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
1 changed files with 3 additions and 2 deletions

View File

@ -64,6 +64,8 @@ utils::stripReplyFromBody(const std::string &bodyi)
body.remove(plainQuote); body.remove(plainQuote);
if (body.startsWith("\n")) if (body.startsWith("\n"))
body.remove(0, 1); body.remove(0, 1);
body.replace("@room", QString::fromUtf8("@\u2060room"));
return body.toStdString(); return body.toStdString();
} }
@ -73,7 +75,7 @@ utils::stripReplyFromFormattedBody(const std::string &formatted_bodyi)
QString formatted_body = QString::fromStdString(formatted_bodyi); QString formatted_body = QString::fromStdString(formatted_bodyi);
formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>", formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>",
QRegularExpression::DotMatchesEverythingOption)); QRegularExpression::DotMatchesEverythingOption));
formatted_body.replace("@room", "@\u2060room"); formatted_body.replace("@room", QString::fromUtf8("@\u2060room"));
return formatted_body.toStdString(); return formatted_body.toStdString();
} }
@ -91,7 +93,6 @@ utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString r
related.quoted_body = related.quoted_body =
QString::fromStdString(stripReplyFromBody(related.quoted_body.toStdString())); QString::fromStdString(stripReplyFromBody(related.quoted_body.toStdString()));
related.quoted_body = utils::getQuoteBody(related); related.quoted_body = utils::getQuoteBody(related);
related.quoted_body.replace("@room", QString::fromUtf8("@\u2060room"));
// get quoted body and strip reply fallback // get quoted body and strip reply fallback
related.quoted_formatted_body = mtx::accessors::formattedBodyWithFallback(event); related.quoted_formatted_body = mtx::accessors::formattedBodyWithFallback(event);