Don't strip fallbacks on plain text bodies

pull/1200/head^2
Nicolas Werner 2 years ago
parent cfcdc23d4a
commit 33403d650a
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 20
      src/timeline/TimelineModel.cpp

@ -585,22 +585,16 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
auto ascent = QFontMetrics(UserSettings::instance()->font()).ascent();
bool isReply = utils::isReply(event);
bool isReply = mtx::accessors::relations(event).reply_to(false).has_value();
auto formattedBody_ = QString::fromStdString(formatted_body(event));
if (formattedBody_.isEmpty()) {
auto body_ = QString::fromStdString(body(event));
if (isReply) {
while (body_.startsWith(QLatin1String("> ")))
body_ = body_.right(body_.size() - body_.indexOf('\n') - 1);
if (body_.startsWith('\n'))
body_ = body_.right(body_.size() - 1);
}
formattedBody_ = body_.toHtmlEscaped().replace('\n', QLatin1String("<br>"));
} else {
if (isReply)
formattedBody_ = formattedBody_.remove(replyFallback);
// NOTE(Nico): replies without html can't have a fallback. If they do, eh, who cares.
formattedBody_ = QString::fromStdString(body(event))
.toHtmlEscaped()
.replace('\n', QLatin1String("<br>"));
} else if (isReply) {
formattedBody_ = formattedBody_.remove(replyFallback);
}
formattedBody_ = utils::escapeBlacklistedHtml(formattedBody_);

Loading…
Cancel
Save