aboutsummaryrefslogtreecommitdiff
path: root/lib/util.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-17 09:03:34 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-24 19:08:20 +0900
commite855085835909549aa866ed968e24902eb378b5a (patch)
tree975797a8b1515b22e7ffeba2e5f385dcf1212663 /lib/util.cpp
parent21e5138f6cf1e96d3cac702e2ada2a0148a3ec92 (diff)
downloadlibquotient-e855085835909549aa866ed968e24902eb378b5a.tar.gz
libquotient-e855085835909549aa866ed968e24902eb378b5a.zip
RoomMemberEvent: sanitize user display names
MemberEventContent::displayName() will strip away Unicode text direction override characters. Direct access to JSON can still provide "raw" data.
Diffstat (limited to 'lib/util.cpp')
-rw-r--r--lib/util.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/util.cpp b/lib/util.cpp
index e1f312ee..8d16cfc8 100644
--- a/lib/util.cpp
+++ b/lib/util.cpp
@@ -63,10 +63,18 @@ static void linkifyUrls(QString& htmlEscapedText)
QStringLiteral(R"(\1<a href="https://matrix.to/#/\2">\2</a>)"));
}
+QString QMatrixClient::sanitized(const QString& plainText)
+{
+ auto text = plainText;
+ text.remove(QChar(0x202e));
+ text.remove(QChar(0x202d));
+ return text;
+}
+
QString QMatrixClient::prettyPrint(const QString& plainText)
{
auto pt = QStringLiteral("<span style='white-space:pre-wrap'>") +
- plainText.toHtmlEscaped() + QStringLiteral("</span>");
+ plainText.toHtmlEscaped() + QStringLiteral("</span>");
pt.replace('\n', QStringLiteral("<br/>"));
linkifyUrls(pt);