diff --git a/src/base/http/server.cpp b/src/base/http/server.cpp index 1cc51eee2..dd5759444 100644 --- a/src/base/http/server.cpp +++ b/src/base/http/server.cpp @@ -28,14 +28,18 @@ * exception statement from your version. */ +#include "server.h" + +#include +#include + #ifndef QT_NO_OPENSSL #include #else #include #endif -#include + #include "connection.h" -#include "server.h" using namespace Http; diff --git a/src/base/utils/string.cpp b/src/base/utils/string.cpp index 7d76d9aaf..6c713b10d 100644 --- a/src/base/utils/string.cpp +++ b/src/base/utils/string.cpp @@ -34,6 +34,7 @@ #include #include #include + #ifdef QBT_USES_QT5 #include #endif @@ -217,6 +218,23 @@ QString Utils::String::toHtmlEscaped(const QString &str) #ifdef QBT_USES_QT5 return str.toHtmlEscaped(); #else - return Qt::escape(str); + // code from Qt + QString rich; + const int len = str.length(); + rich.reserve(int(len * 1.1)); + for (int i = 0; i < len; ++i) { + if (str.at(i) == QLatin1Char('<')) + rich += QLatin1String("<"); + else if (str.at(i) == QLatin1Char('>')) + rich += QLatin1String(">"); + else if (str.at(i) == QLatin1Char('&')) + rich += QLatin1String("&"); + else if (str.at(i) == QLatin1Char('"')) + rich += QLatin1String("""); + else + rich += str.at(i); + } + rich.squeeze(); + return rich; #endif }