mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 00:17:23 -06:00
Rename literal operator
Qt 6.4 introduced `QString operator""_s()` and the previous `""_qs` is deprecated since Qt 6.8.
This commit is contained in:
@@ -82,8 +82,8 @@ void Connection::read()
|
||||
LogMsg(tr("Http request size exceeds limitation, closing socket. Limit: %1, IP: %2")
|
||||
.arg(bufferLimit).arg(m_socket->peerAddress().toString()), Log::WARNING);
|
||||
|
||||
Response resp(413, u"Payload Too Large"_qs);
|
||||
resp.headers[HEADER_CONNECTION] = u"close"_qs;
|
||||
Response resp(413, u"Payload Too Large"_s);
|
||||
resp.headers[HEADER_CONNECTION] = u"close"_s;
|
||||
|
||||
sendResponse(resp);
|
||||
m_socket->close();
|
||||
@@ -96,8 +96,8 @@ void Connection::read()
|
||||
LogMsg(tr("Bad Http request, closing socket. IP: %1")
|
||||
.arg(m_socket->peerAddress().toString()), Log::WARNING);
|
||||
|
||||
Response resp(400, u"Bad Request"_qs);
|
||||
resp.headers[HEADER_CONNECTION] = u"close"_qs;
|
||||
Response resp(400, u"Bad Request"_s);
|
||||
resp.headers[HEADER_CONNECTION] = u"close"_s;
|
||||
|
||||
sendResponse(resp);
|
||||
m_socket->close();
|
||||
@@ -110,10 +110,10 @@ void Connection::read()
|
||||
|
||||
Response resp = m_requestHandler->processRequest(result.request, env);
|
||||
|
||||
if (acceptsGzipEncoding(result.request.headers[u"accept-encoding"_qs]))
|
||||
resp.headers[HEADER_CONTENT_ENCODING] = u"gzip"_qs;
|
||||
if (acceptsGzipEncoding(result.request.headers[u"accept-encoding"_s]))
|
||||
resp.headers[HEADER_CONTENT_ENCODING] = u"gzip"_s;
|
||||
|
||||
resp.headers[HEADER_CONNECTION] = u"keep-alive"_qs;
|
||||
resp.headers[HEADER_CONNECTION] = u"keep-alive"_s;
|
||||
|
||||
sendResponse(resp);
|
||||
m_receivedData = m_receivedData.mid(result.frameSize);
|
||||
@@ -176,11 +176,11 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
const bool canGzip = isCodingAvailable(list, u"gzip"_qs);
|
||||
const bool canGzip = isCodingAvailable(list, u"gzip"_s);
|
||||
if (canGzip)
|
||||
return true;
|
||||
|
||||
const bool canAny = isCodingAvailable(list, u"*"_qs);
|
||||
const bool canAny = isCodingAvailable(list, u"*"_s);
|
||||
if (canAny)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -48,41 +48,41 @@ QString HTTPError::statusText() const
|
||||
}
|
||||
|
||||
BadRequestHTTPError::BadRequestHTTPError(const QString &message)
|
||||
: HTTPError(400, u"Bad Request"_qs, message)
|
||||
: HTTPError(400, u"Bad Request"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
UnauthorizedHTTPError::UnauthorizedHTTPError(const QString &message)
|
||||
: HTTPError(401, u"Unauthorized"_qs, message)
|
||||
: HTTPError(401, u"Unauthorized"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
ForbiddenHTTPError::ForbiddenHTTPError(const QString &message)
|
||||
: HTTPError(403, u"Forbidden"_qs, message)
|
||||
: HTTPError(403, u"Forbidden"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
NotFoundHTTPError::NotFoundHTTPError(const QString &message)
|
||||
: HTTPError(404, u"Not Found"_qs, message)
|
||||
: HTTPError(404, u"Not Found"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
MethodNotAllowedHTTPError::MethodNotAllowedHTTPError(const QString &message)
|
||||
: HTTPError(405, u"Method Not Allowed"_qs, message)
|
||||
: HTTPError(405, u"Method Not Allowed"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
ConflictHTTPError::ConflictHTTPError(const QString &message)
|
||||
: HTTPError(409, u"Conflict"_qs, message)
|
||||
: HTTPError(409, u"Conflict"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
UnsupportedMediaTypeHTTPError::UnsupportedMediaTypeHTTPError(const QString &message)
|
||||
: HTTPError(415, u"Unsupported Media Type"_qs, message)
|
||||
: HTTPError(415, u"Unsupported Media Type"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
InternalServerErrorHTTPError::InternalServerErrorHTTPError(const QString &message)
|
||||
: HTTPError(500, u"Internal Server Error"_qs, message)
|
||||
: HTTPError(500, u"Internal Server Error"_s, message)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ bool RequestParser::parseRequestLine(const QString &line)
|
||||
{
|
||||
// [rfc7230] 3.1.1. Request Line
|
||||
|
||||
const QRegularExpression re(u"^([A-Z]+)\\s+(\\S+)\\s+HTTP\\/(\\d\\.\\d)$"_qs);
|
||||
const QRegularExpression re(u"^([A-Z]+)\\s+(\\S+)\\s+HTTP\\/(\\d\\.\\d)$"_s);
|
||||
const QRegularExpressionMatch match = re.match(line);
|
||||
|
||||
if (!match.hasMatch())
|
||||
@@ -264,7 +264,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
||||
// [rfc2046] 5.1.1. Common Syntax
|
||||
|
||||
// find boundary delimiter
|
||||
const QString boundaryFieldName = u"boundary="_qs;
|
||||
const QString boundaryFieldName = u"boundary="_s;
|
||||
const int idx = contentType.indexOf(boundaryFieldName);
|
||||
if (idx < 0)
|
||||
{
|
||||
@@ -343,8 +343,8 @@ bool RequestParser::parseFormData(const QByteArray &data)
|
||||
}
|
||||
|
||||
// pick data
|
||||
const QString filename = u"filename"_qs;
|
||||
const QString name = u"name"_qs;
|
||||
const QString filename = u"filename"_s;
|
||||
const QString name = u"name"_s;
|
||||
|
||||
if (headersMap.contains(filename))
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Http
|
||||
class ResponseBuilder
|
||||
{
|
||||
public:
|
||||
void status(uint code = 200, const QString &text = u"OK"_qs);
|
||||
void status(uint code = 200, const QString &text = u"OK"_s);
|
||||
void setHeader(const Header &header);
|
||||
void print(const QString &text, const QString &type = CONTENT_TYPE_HTML);
|
||||
void print(const QByteArray &data, const QString &type = CONTENT_TYPE_HTML);
|
||||
|
||||
@@ -74,7 +74,7 @@ QString Http::httpDate()
|
||||
// [RFC 7231] 7.1.1.1. Date/Time Formats
|
||||
// example: "Sun, 06 Nov 1994 08:49:37 GMT"
|
||||
|
||||
return QLocale::c().toString(QDateTime::currentDateTimeUtc(), u"ddd, dd MMM yyyy HH:mm:ss"_qs)
|
||||
return QLocale::c().toString(QDateTime::currentDateTimeUtc(), u"ddd, dd MMM yyyy HH:mm:ss"_s)
|
||||
.append(u" GMT");
|
||||
}
|
||||
|
||||
@@ -106,5 +106,5 @@ void Http::compressContent(Response &response)
|
||||
return;
|
||||
|
||||
response.content = compressedData;
|
||||
response.headers[HEADER_CONTENT_ENCODING] = u"gzip"_qs;
|
||||
response.headers[HEADER_CONTENT_ENCODING] = u"gzip"_s;
|
||||
}
|
||||
|
||||
@@ -55,28 +55,28 @@ namespace
|
||||
|
||||
QList<QSslCipher> safeCipherList()
|
||||
{
|
||||
const QStringList badCiphers {u"idea"_qs, u"rc4"_qs};
|
||||
const QStringList badCiphers {u"idea"_s, u"rc4"_s};
|
||||
// Contains Ciphersuites that use RSA for the Key Exchange but they don't mention it in their name
|
||||
const QStringList badRSAShorthandSuites {
|
||||
u"AES256-GCM-SHA384"_qs, u"AES128-GCM-SHA256"_qs, u"AES256-SHA256"_qs,
|
||||
u"AES128-SHA256"_qs, u"AES256-SHA"_qs, u"AES128-SHA"_qs};
|
||||
u"AES256-GCM-SHA384"_s, u"AES128-GCM-SHA256"_s, u"AES256-SHA256"_s,
|
||||
u"AES128-SHA256"_s, u"AES256-SHA"_s, u"AES128-SHA"_s};
|
||||
// Contains Ciphersuites that use AES CBC mode but they don't mention it in their name
|
||||
const QStringList badAESShorthandSuites {
|
||||
u"ECDHE-ECDSA-AES256-SHA384"_qs, u"ECDHE-RSA-AES256-SHA384"_qs, u"DHE-RSA-AES256-SHA256"_qs,
|
||||
u"ECDHE-ECDSA-AES128-SHA256"_qs, u"ECDHE-RSA-AES128-SHA256"_qs, u"DHE-RSA-AES128-SHA256"_qs,
|
||||
u"ECDHE-ECDSA-AES256-SHA"_qs, u"ECDHE-RSA-AES256-SHA"_qs, u"DHE-RSA-AES256-SHA"_qs,
|
||||
u"ECDHE-ECDSA-AES128-SHA"_qs, u"ECDHE-RSA-AES128-SHA"_qs, u"DHE-RSA-AES128-SHA"_qs};
|
||||
u"ECDHE-ECDSA-AES256-SHA384"_s, u"ECDHE-RSA-AES256-SHA384"_s, u"DHE-RSA-AES256-SHA256"_s,
|
||||
u"ECDHE-ECDSA-AES128-SHA256"_s, u"ECDHE-RSA-AES128-SHA256"_s, u"DHE-RSA-AES128-SHA256"_s,
|
||||
u"ECDHE-ECDSA-AES256-SHA"_s, u"ECDHE-RSA-AES256-SHA"_s, u"DHE-RSA-AES256-SHA"_s,
|
||||
u"ECDHE-ECDSA-AES128-SHA"_s, u"ECDHE-RSA-AES128-SHA"_s, u"DHE-RSA-AES128-SHA"_s};
|
||||
const QList<QSslCipher> allCiphers {QSslConfiguration::supportedCiphers()};
|
||||
QList<QSslCipher> safeCiphers;
|
||||
std::copy_if(allCiphers.cbegin(), allCiphers.cend(), std::back_inserter(safeCiphers),
|
||||
[&badCiphers, &badRSAShorthandSuites, &badAESShorthandSuites](const QSslCipher &cipher)
|
||||
{
|
||||
const QString name = cipher.name();
|
||||
if (name.contains(u"-cbc-"_qs, Qt::CaseInsensitive) // AES CBC mode is considered vulnerable to BEAST attack
|
||||
|| name.startsWith(u"adh-"_qs, Qt::CaseInsensitive) // Key Exchange: Diffie-Hellman, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"aecdh-"_qs, Qt::CaseInsensitive) // Key Exchange: Elliptic Curve Diffie-Hellman, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"psk-"_qs, Qt::CaseInsensitive) // Key Exchange: Pre-Shared Key, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"rsa-"_qs, Qt::CaseInsensitive) // Key Exchange: Rivest Shamir Adleman (RSA), doesn't support Perfect Forward Secrecy
|
||||
if (name.contains(u"-cbc-"_s, Qt::CaseInsensitive) // AES CBC mode is considered vulnerable to BEAST attack
|
||||
|| name.startsWith(u"adh-"_s, Qt::CaseInsensitive) // Key Exchange: Diffie-Hellman, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"aecdh-"_s, Qt::CaseInsensitive) // Key Exchange: Elliptic Curve Diffie-Hellman, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"psk-"_s, Qt::CaseInsensitive) // Key Exchange: Pre-Shared Key, doesn't support Perfect Forward Secrecy
|
||||
|| name.startsWith(u"rsa-"_s, Qt::CaseInsensitive) // Key Exchange: Rivest Shamir Adleman (RSA), doesn't support Perfect Forward Secrecy
|
||||
|| badRSAShorthandSuites.contains(name, Qt::CaseInsensitive)
|
||||
|| badAESShorthandSuites.contains(name, Qt::CaseInsensitive))
|
||||
{
|
||||
|
||||
@@ -37,42 +37,42 @@
|
||||
|
||||
namespace Http
|
||||
{
|
||||
inline const QString METHOD_GET = u"GET"_qs;
|
||||
inline const QString METHOD_POST = u"POST"_qs;
|
||||
inline const QString METHOD_GET = u"GET"_s;
|
||||
inline const QString METHOD_POST = u"POST"_s;
|
||||
|
||||
inline const QString HEADER_CACHE_CONTROL = u"cache-control"_qs;
|
||||
inline const QString HEADER_CONNECTION = u"connection"_qs;
|
||||
inline const QString HEADER_CONTENT_DISPOSITION = u"content-disposition"_qs;
|
||||
inline const QString HEADER_CONTENT_ENCODING = u"content-encoding"_qs;
|
||||
inline const QString HEADER_CONTENT_LENGTH = u"content-length"_qs;
|
||||
inline const QString HEADER_CONTENT_SECURITY_POLICY = u"content-security-policy"_qs;
|
||||
inline const QString HEADER_CONTENT_TYPE = u"content-type"_qs;
|
||||
inline const QString HEADER_CROSS_ORIGIN_OPENER_POLICY = u"cross-origin-opener-policy"_qs;
|
||||
inline const QString HEADER_DATE = u"date"_qs;
|
||||
inline const QString HEADER_HOST = u"host"_qs;
|
||||
inline const QString HEADER_ORIGIN = u"origin"_qs;
|
||||
inline const QString HEADER_REFERER = u"referer"_qs;
|
||||
inline const QString HEADER_REFERRER_POLICY = u"referrer-policy"_qs;
|
||||
inline const QString HEADER_SET_COOKIE = u"set-cookie"_qs;
|
||||
inline const QString HEADER_X_CONTENT_TYPE_OPTIONS = u"x-content-type-options"_qs;
|
||||
inline const QString HEADER_X_FORWARDED_FOR = u"x-forwarded-for"_qs;
|
||||
inline const QString HEADER_X_FORWARDED_HOST = u"x-forwarded-host"_qs;
|
||||
inline const QString HEADER_X_FRAME_OPTIONS = u"x-frame-options"_qs;
|
||||
inline const QString HEADER_X_XSS_PROTECTION = u"x-xss-protection"_qs;
|
||||
inline const QString HEADER_CACHE_CONTROL = u"cache-control"_s;
|
||||
inline const QString HEADER_CONNECTION = u"connection"_s;
|
||||
inline const QString HEADER_CONTENT_DISPOSITION = u"content-disposition"_s;
|
||||
inline const QString HEADER_CONTENT_ENCODING = u"content-encoding"_s;
|
||||
inline const QString HEADER_CONTENT_LENGTH = u"content-length"_s;
|
||||
inline const QString HEADER_CONTENT_SECURITY_POLICY = u"content-security-policy"_s;
|
||||
inline const QString HEADER_CONTENT_TYPE = u"content-type"_s;
|
||||
inline const QString HEADER_CROSS_ORIGIN_OPENER_POLICY = u"cross-origin-opener-policy"_s;
|
||||
inline const QString HEADER_DATE = u"date"_s;
|
||||
inline const QString HEADER_HOST = u"host"_s;
|
||||
inline const QString HEADER_ORIGIN = u"origin"_s;
|
||||
inline const QString HEADER_REFERER = u"referer"_s;
|
||||
inline const QString HEADER_REFERRER_POLICY = u"referrer-policy"_s;
|
||||
inline const QString HEADER_SET_COOKIE = u"set-cookie"_s;
|
||||
inline const QString HEADER_X_CONTENT_TYPE_OPTIONS = u"x-content-type-options"_s;
|
||||
inline const QString HEADER_X_FORWARDED_FOR = u"x-forwarded-for"_s;
|
||||
inline const QString HEADER_X_FORWARDED_HOST = u"x-forwarded-host"_s;
|
||||
inline const QString HEADER_X_FRAME_OPTIONS = u"x-frame-options"_s;
|
||||
inline const QString HEADER_X_XSS_PROTECTION = u"x-xss-protection"_s;
|
||||
|
||||
inline const QString HEADER_REQUEST_METHOD_GET = u"GET"_qs;
|
||||
inline const QString HEADER_REQUEST_METHOD_HEAD = u"HEAD"_qs;
|
||||
inline const QString HEADER_REQUEST_METHOD_POST = u"POST"_qs;
|
||||
inline const QString HEADER_REQUEST_METHOD_GET = u"GET"_s;
|
||||
inline const QString HEADER_REQUEST_METHOD_HEAD = u"HEAD"_s;
|
||||
inline const QString HEADER_REQUEST_METHOD_POST = u"POST"_s;
|
||||
|
||||
inline const QString CONTENT_TYPE_HTML = u"text/html"_qs;
|
||||
inline const QString CONTENT_TYPE_CSS = u"text/css"_qs;
|
||||
inline const QString CONTENT_TYPE_TXT = u"text/plain; charset=UTF-8"_qs;
|
||||
inline const QString CONTENT_TYPE_JS = u"application/javascript"_qs;
|
||||
inline const QString CONTENT_TYPE_JSON = u"application/json"_qs;
|
||||
inline const QString CONTENT_TYPE_GIF = u"image/gif"_qs;
|
||||
inline const QString CONTENT_TYPE_PNG = u"image/png"_qs;
|
||||
inline const QString CONTENT_TYPE_FORM_ENCODED = u"application/x-www-form-urlencoded"_qs;
|
||||
inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_qs;
|
||||
inline const QString CONTENT_TYPE_HTML = u"text/html"_s;
|
||||
inline const QString CONTENT_TYPE_CSS = u"text/css"_s;
|
||||
inline const QString CONTENT_TYPE_TXT = u"text/plain; charset=UTF-8"_s;
|
||||
inline const QString CONTENT_TYPE_JS = u"application/javascript"_s;
|
||||
inline const QString CONTENT_TYPE_JSON = u"application/json"_s;
|
||||
inline const QString CONTENT_TYPE_GIF = u"image/gif"_s;
|
||||
inline const QString CONTENT_TYPE_PNG = u"image/png"_s;
|
||||
inline const QString CONTENT_TYPE_FORM_ENCODED = u"application/x-www-form-urlencoded"_s;
|
||||
inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_s;
|
||||
|
||||
// portability: "\r\n" doesn't guarantee mapping to the correct symbol
|
||||
inline const char CRLF[] = {0x0D, 0x0A, '\0'};
|
||||
@@ -124,7 +124,7 @@ namespace Http
|
||||
HeaderMap headers;
|
||||
QByteArray content;
|
||||
|
||||
Response(uint code = 200, const QString &text = u"OK"_qs)
|
||||
Response(uint code = 200, const QString &text = u"OK"_s)
|
||||
: status {code, text}
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user