online nicks with spec symbols fix

master
const an teen 2021-12-27 05:14:32 -05:00
parent ec8c360399
commit 67e12fee8f
1 changed files with 13 additions and 17 deletions

View File

@ -63,12 +63,7 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
if (nick.isEmpty()) {
return result;
}
QString text {rawLine};
text.remove(QRegularExpression("^\\[[^\\s]*\\]\\s"));
if (text.isEmpty()) {
return result;
}
nick = nick.toHtmlEscaped();
// long nicks
if (nick.size() > MAX_NICKNAME_LENGTH_WITHOUT_WBR) {
@ -81,6 +76,11 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
}
}
QString text {rawLine};
text.remove(QRegularExpression("^\\[[^\\s]*\\]\\s"));
if (text.isEmpty()) {
return result;
}
text = text.toHtmlEscaped();
// http links
@ -143,9 +143,9 @@ void HttpServer::consoleLog(const QString &message)
void HttpServer::debugLog(const QString &req)
{
QFile log(m_logFolder + "httprequests.log");
QFile log(m_logFolder + "debug.log");
if (log.open(QIODevice::WriteOnly | QIODevice::Append)) {
log.write(QDateTime::currentDateTime().toString().toUtf8() + ":\n" + req.toUtf8() + "\n");
log.write(QDateTime::currentDateTime().toString().toUtf8() + ":\n" + req.toUtf8() + "\n\n");
log.close();
}
}
@ -599,7 +599,7 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
int currentOnline = 0;
QString onlineUserS;
for (const auto &user: m_onlineUsers[originalServerName][originalChannelName]) {
if (QRegularExpression("^(@|\\&|\\+|~)?"+m_botsNick[originalServerName]+"$").match(user).hasMatch()) {
if (QRegularExpression("^(.*;|~|@|\\&|\\+)?"+m_botsNick[originalServerName]+"$").match(user).hasMatch()) {
continue;
}
QString onlineUser = HTML_ONLINE_POINT;
@ -719,13 +719,12 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
counter++;
QString message = HTML_PAYLOAD_LIST_CHAT_MESSAGE;
for (const auto &user: m_onlineUsers[originalServerName][originalChannelName]) {
if (QRegularExpression("^.?"+rawMessage.first+"$").match(user).hasMatch()) {
if (QRegularExpression("^(.*;|~|@|\\&|\\+)?"+rawMessage.first+"$").match(user).hasMatch()) {
message.replace("<div class=\"main_payload__chat_username\">",
"<div class=\"main_payload__chat_username\" style=\"color: green\">");
break;
}
}
rawMessage.first = rawMessage.first.toHtmlEscaped();
replaceTag(message, "USERNAME", rawMessage.first);
replaceTag(message, "MESSAGE_TEXT", rawMessage.second);
matchedPathsAndMessages[path].push_back(message);
@ -777,13 +776,12 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
counter++;
QString message = HTML_PAYLOAD_LIST_CHAT_MESSAGE;
for (const auto &user: m_onlineUsers[originalServerName][originalChannelName]) {
if (QRegularExpression("^.?"+rawMessage.first+"$").match(user).hasMatch()) {
if (QRegularExpression("^^(.*;|~|@|\\&|\\+)?"+rawMessage.first+"$").match(user).hasMatch()) {
message.replace("<div class=\"main_payload__chat_username\">",
"<div class=\"main_payload__chat_username\" style=\"color: green\">");
break;
}
}
rawMessage.first = rawMessage.first.toHtmlEscaped();
replaceTag(message, "USERNAME", rawMessage.first);
replaceTag(message, "MESSAGE_TEXT", rawMessage.second);
matchedPathsAndMessages[path].push_back(message);
@ -858,13 +856,12 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
counter++;
QString message = HTML_PAYLOAD_LIST_CHAT_MESSAGE;
for (const auto &user: m_onlineUsers[originalServerName][originalChannelName]) {
if (QRegularExpression("^.?"+rawMessage.first+"$").match(user).hasMatch()) {
if (QRegularExpression("^^(.*;|~|@|\\&|\\+)?"+rawMessage.first+"$").match(user).hasMatch()) {
message.replace("<div class=\"main_payload__chat_username\">",
"<div class=\"main_payload__chat_username\" style=\"color: green\">");
break;
}
}
rawMessage.first = rawMessage.first.toHtmlEscaped();
replaceTag(message, "USERNAME", rawMessage.first);
replaceTag(message, "MESSAGE_TEXT", rawMessage.second);
matchedPathsAndMessages[path].push_back(message);
@ -1036,13 +1033,12 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
QString message = HTML_PAYLOAD_LIST_CHAT_MESSAGE;
for (const auto &user: m_onlineUsers[originalServerName][originalChannelName]) {
if (QRegularExpression("^(@|\\&|\\+|~)?"+rawMessage.first+"$").match(user).hasMatch()) {
if (QRegularExpression("^(.*;|~|@|\\&|\\+)?"+rawMessage.first+"$").match(user).hasMatch()) {
message.replace("<div class=\"main_payload__chat_username\">",
"<div class=\"main_payload__chat_username\" style=\"color: green\">");
break;
}
}
rawMessage.first = rawMessage.first.toHtmlEscaped();
replaceTag(message, "USERNAME", rawMessage.first);
replaceTag(message, "MESSAGE_TEXT", rawMessage.second);
payloadBlock += message;