diff --git a/src/chatlog/content/text.cpp b/src/chatlog/content/text.cpp index 032b85c8b..7660af746 100644 --- a/src/chatlog/content/text.cpp +++ b/src/chatlog/content/text.cpp @@ -286,3 +286,14 @@ void Text::detectAnchors() offset += htmledUrl.length(); } } + +QString Text::toHtmlChars(const QString &str) +{ + static QList> replaceList = {{"&","&"}, {">",">"}, {"<","<"}}; + QString res = str; + + for (auto &it : replaceList) + res = res.replace(it.first,it.second); + + return res; +} diff --git a/src/chatlog/content/text.h b/src/chatlog/content/text.h index 61b5ee866..8ef17499b 100644 --- a/src/chatlog/content/text.h +++ b/src/chatlog/content/text.h @@ -62,6 +62,7 @@ protected: int cursorFromPos(QPointF scenePos) const; void detectAnchors(); + QString toHtmlChars(const QString& str); private: CustomTextDocument* doc = nullptr;