mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
use QString::toHtmlEscaped
This commit is contained in:
parent
a930b398d4
commit
e454671ebd
|
@ -39,7 +39,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
|
||||||
{
|
{
|
||||||
ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage);
|
ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage);
|
||||||
|
|
||||||
QString text = toHtmlChars(rawMessage);
|
QString text = rawMessage.toHtmlEscaped();
|
||||||
QString senderText = sender;
|
QString senderText = sender;
|
||||||
|
|
||||||
const QColor actionColor = QColor("#1818FF"); // has to match the color in innerStyle.css (div.action)
|
const QColor actionColor = QColor("#1818FF"); // has to match the color in innerStyle.css (div.action)
|
||||||
|
@ -79,7 +79,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
|
||||||
ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString &rawMessage, SystemMessageType type, const QDateTime &date)
|
ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString &rawMessage, SystemMessageType type, const QDateTime &date)
|
||||||
{
|
{
|
||||||
ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage);
|
ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage);
|
||||||
QString text = toHtmlChars(rawMessage);
|
QString text = rawMessage.toHtmlEscaped();
|
||||||
|
|
||||||
QString img;
|
QString img;
|
||||||
switch(type)
|
switch(type)
|
||||||
|
@ -217,17 +217,6 @@ QString ChatMessage::detectQuotes(const QString& str)
|
||||||
return quotedText;
|
return quotedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChatMessage::toHtmlChars(const QString &str)
|
|
||||||
{
|
|
||||||
static QList<QPair<QString, QString>> replaceList = {{"&","&"}, {">",">"}, {"<","<"}};
|
|
||||||
QString res = str;
|
|
||||||
|
|
||||||
for (auto &it : replaceList)
|
|
||||||
res = res.replace(it.first,it.second);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChatMessage::wrapDiv(const QString &str, const QString &div)
|
QString ChatMessage::wrapDiv(const QString &str, const QString &div)
|
||||||
{
|
{
|
||||||
return QString("<div class=%1>%2</div>").arg(div, str);
|
return QString("<div class=%1>%2</div>").arg(div, str);
|
||||||
|
|
|
@ -60,7 +60,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
static QString detectAnchors(const QString& str);
|
static QString detectAnchors(const QString& str);
|
||||||
static QString detectQuotes(const QString& str);
|
static QString detectQuotes(const QString& str);
|
||||||
static QString toHtmlChars(const QString& str);
|
|
||||||
static QString wrapDiv(const QString& str, const QString& div);
|
static QString wrapDiv(const QString& str, const QString& div);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user