mirror of https://notabug.org/acetone/ircabot.git
final html tags fixes
parent
6f520c4575
commit
76e1d6a1de
|
@ -70,10 +70,10 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
|||
return result;
|
||||
}
|
||||
|
||||
text.replace('&', "&");
|
||||
text.replace('<', "<");
|
||||
text.replace('>', ">");
|
||||
text.replace('\"', """);
|
||||
nick.replace('&', "&");
|
||||
nick.replace('<', "<");
|
||||
nick.replace('>', ">");
|
||||
nick.replace('\"', """);
|
||||
|
||||
// long nicks
|
||||
if (nick.size() > MAX_NICKNAME_LENGTH_WITHOUT_WBR) {
|
||||
|
@ -86,6 +86,11 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
|||
}
|
||||
}
|
||||
|
||||
text.replace('&', "&");
|
||||
text.replace('<', "<");
|
||||
text.replace('>', ">");
|
||||
text.replace('\"', """);
|
||||
|
||||
// http links
|
||||
while (QRegularExpression("(^|\\s)http.?://").match(text).hasMatch()) {
|
||||
int pos = text.indexOf(QRegularExpression("(^|\\s)http.?://"));
|
||||
|
@ -106,6 +111,7 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
|||
}
|
||||
// long lines
|
||||
int space = 0;
|
||||
bool nbTag = false; // For safe HTML tags like a ⁢ via <wbr>!
|
||||
bool isHref = false;
|
||||
for (int i = 0; i < text.size(); i++) {
|
||||
if (text[i] == ' ') {
|
||||
|
@ -119,7 +125,15 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
|||
}
|
||||
}
|
||||
}
|
||||
if (not isHref and i-space > MAX_MESSAGE_LENGTH_WITHOUT_WBR) {
|
||||
|
||||
if (nbTag and text[i] == ';') {
|
||||
nbTag = false;
|
||||
}
|
||||
if (text.indexOf(QRegularExpression("(\\&|\\<|\\>|\\").*"), i) == i) {
|
||||
nbTag = true;
|
||||
}
|
||||
|
||||
if (not isHref and i-space > MAX_MESSAGE_LENGTH_WITHOUT_WBR and not nbTag) {
|
||||
text.insert(i, "<wbr>");
|
||||
space = i;
|
||||
}
|
||||
|
@ -818,7 +832,7 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath, bool isHead
|
|||
for(const auto& m: messages) {
|
||||
payloadBlock += m;
|
||||
}
|
||||
payloadBlock += " ";
|
||||
payloadBlock += " \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
main.cpp
2
main.cpp
|
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
|||
" | $$ | $$ \\ $$| $$ $$ /$$__ $$| $$ \\ $$| $$ | $$ | $$ /$$\n"
|
||||
" /$$$$$$| $$ | $$| $$$$$$/| $$$$$$$| $$$$$$$/| $$$$$$/ | $$$$/\n"
|
||||
"|______/|__/ |__/ \\______/ \\_______/|_______/ \\______/ \\___/";
|
||||
qInfo().noquote() << "IRCaBot" << IRCABOT_VERSION << " | Source code: https://notabug.org/acetone/ircabot";
|
||||
qInfo().noquote() << "IRCaBot" << IRCABOT_VERSION << "| Source code: https://notabug.org/acetone/ircabot";
|
||||
qInfo().noquote() << "GPLv3 (c) acetone," << COPYRIGHT_YEAR << "\n";
|
||||
|
||||
ApplicationData configuration(configFile);
|
||||
|
|
Loading…
Reference in New Issue