Revise string literal usage

PR #16703.
This commit is contained in:
Chocobo1
2022-03-26 11:53:50 +08:00
committed by GitHub
parent e1abcc684a
commit 4ca6de2b54
55 changed files with 485 additions and 472 deletions

View File

@@ -637,7 +637,7 @@ void AppController::setPreferencesAction()
if (pref->getLocale() != locale)
{
auto *translator = new QTranslator;
if (translator->load(QLatin1String(":/lang/qbittorrent_") + locale))
if (translator->load(u":/lang/qbittorrent_"_qs + locale))
{
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
}

View File

@@ -41,7 +41,7 @@ void AuthController::loginAction()
{
if (sessionManager()->session())
{
setResult(QLatin1String("Ok."));
setResult(u"Ok."_qs);
return;
}
@@ -70,14 +70,14 @@ void AuthController::loginAction()
m_clientFailedLogins.remove(clientAddr);
sessionManager()->sessionStart();
setResult(QLatin1String("Ok."));
setResult(u"Ok."_qs);
LogMsg(tr("WebAPI login success. IP: %1").arg(clientAddr));
}
else
{
if (Preferences::instance()->getWebUIMaxAuthFailCount() > 0)
increaseFailedAttempts();
setResult(QLatin1String("Fails."));
setResult(u"Fails."_qs);
LogMsg(tr("WebAPI login failure. Reason: invalid credentials, attempt count: %1, IP: %2, username: %3")
.arg(QString::number(failedAttemptsCount()), clientAddr, usernameFromWeb)
, Log::WARNING);

View File

@@ -36,13 +36,13 @@
#include "base/logger.h"
#include "base/utils/string.h"
const char KEY_LOG_ID[] = "id";
const char KEY_LOG_TIMESTAMP[] = "timestamp";
const char KEY_LOG_MSG_TYPE[] = "type";
const char KEY_LOG_MSG_MESSAGE[] = "message";
const char KEY_LOG_PEER_IP[] = "ip";
const char KEY_LOG_PEER_BLOCKED[] = "blocked";
const char KEY_LOG_PEER_REASON[] = "reason";
const QString KEY_LOG_ID = u"id"_qs;
const QString KEY_LOG_TIMESTAMP = u"timestamp"_qs;
const QString KEY_LOG_MSG_TYPE = u"type"_qs;
const QString KEY_LOG_MSG_MESSAGE = u"message"_qs;
const QString KEY_LOG_PEER_IP = u"ip"_qs;
const QString KEY_LOG_PEER_BLOCKED = u"blocked"_qs;
const QString KEY_LOG_PEER_REASON = u"reason"_qs;
// Returns the log in JSON format.
// The return value is an array of dictionaries.
@@ -84,10 +84,10 @@ void LogController::mainAction()
msgList.append(QJsonObject
{
{QLatin1String(KEY_LOG_ID), msg.id},
{QLatin1String(KEY_LOG_TIMESTAMP), msg.timestamp},
{QLatin1String(KEY_LOG_MSG_TYPE), msg.type},
{QLatin1String(KEY_LOG_MSG_MESSAGE), msg.message}
{KEY_LOG_ID, msg.id},
{KEY_LOG_TIMESTAMP, msg.timestamp},
{KEY_LOG_MSG_TYPE, msg.type},
{KEY_LOG_MSG_MESSAGE, msg.message}
});
}
@@ -118,11 +118,11 @@ void LogController::peersAction()
{
peerList.append(QJsonObject
{
{QLatin1String(KEY_LOG_ID), peer.id},
{QLatin1String(KEY_LOG_TIMESTAMP), peer.timestamp},
{QLatin1String(KEY_LOG_PEER_IP), peer.ip},
{QLatin1String(KEY_LOG_PEER_BLOCKED), peer.blocked},
{QLatin1String(KEY_LOG_PEER_REASON), peer.reason}
{KEY_LOG_ID, peer.id},
{KEY_LOG_TIMESTAMP, peer.timestamp},
{KEY_LOG_PEER_IP, peer.ip},
{KEY_LOG_PEER_BLOCKED, peer.blocked},
{KEY_LOG_PEER_REASON, peer.reason}
});
}

View File

@@ -50,8 +50,8 @@ using SearchHandlerDict = QMap<int, SearchHandlerPtr>;
namespace
{
const QLatin1String ACTIVE_SEARCHES("activeSearches");
const QLatin1String SEARCH_HANDLERS("searchHandlers");
const QString ACTIVE_SEARCHES = u"activeSearches"_qs;
const QString SEARCH_HANDLERS = u"searchHandlers"_qs;
void removeActiveSearch(ISession *session, const int id)
{
@@ -72,8 +72,8 @@ namespace
{
QJsonArray categoriesInfo
{QJsonObject {
{QLatin1String("id"), u"all"_qs},
{QLatin1String("name"), SearchPluginManager::categoryFullName(u"all"_qs)}
{u"id"_qs, u"all"_qs},
{u"name"_qs, SearchPluginManager::categoryFullName(u"all"_qs)}
}};
categories.sort(Qt::CaseInsensitive);
@@ -81,8 +81,8 @@ namespace
{
categoriesInfo << QJsonObject
{
{QLatin1String("id"), category},
{QLatin1String("name"), SearchPluginManager::categoryFullName(category)}
{u"id"_qs, category},
{u"name"_qs, SearchPluginManager::categoryFullName(category)}
};
}

View File

@@ -45,43 +45,43 @@ namespace
switch (state)
{
case BitTorrent::TorrentState::Error:
return QLatin1String("error");
return u"error"_qs;
case BitTorrent::TorrentState::MissingFiles:
return QLatin1String("missingFiles");
return u"missingFiles"_qs;
case BitTorrent::TorrentState::Uploading:
return QLatin1String("uploading");
return u"uploading"_qs;
case BitTorrent::TorrentState::PausedUploading:
return QLatin1String("pausedUP");
return u"pausedUP"_qs;
case BitTorrent::TorrentState::QueuedUploading:
return QLatin1String("queuedUP");
return u"queuedUP"_qs;
case BitTorrent::TorrentState::StalledUploading:
return QLatin1String("stalledUP");
return u"stalledUP"_qs;
case BitTorrent::TorrentState::CheckingUploading:
return QLatin1String("checkingUP");
return u"checkingUP"_qs;
case BitTorrent::TorrentState::ForcedUploading:
return QLatin1String("forcedUP");
return u"forcedUP"_qs;
case BitTorrent::TorrentState::Downloading:
return QLatin1String("downloading");
return u"downloading"_qs;
case BitTorrent::TorrentState::DownloadingMetadata:
return QLatin1String("metaDL");
return u"metaDL"_qs;
case BitTorrent::TorrentState::ForcedDownloadingMetadata:
return QLatin1String("forcedMetaDL");
return u"forcedMetaDL"_qs;
case BitTorrent::TorrentState::PausedDownloading:
return QLatin1String("pausedDL");
return u"pausedDL"_qs;
case BitTorrent::TorrentState::QueuedDownloading:
return QLatin1String("queuedDL");
return u"queuedDL"_qs;
case BitTorrent::TorrentState::StalledDownloading:
return QLatin1String("stalledDL");
return u"stalledDL"_qs;
case BitTorrent::TorrentState::CheckingDownloading:
return QLatin1String("checkingDL");
return u"checkingDL"_qs;
case BitTorrent::TorrentState::ForcedDownloading:
return QLatin1String("forcedDL");
return u"forcedDL"_qs;
case BitTorrent::TorrentState::CheckingResumeData:
return QLatin1String("checkingResumeData");
return u"checkingResumeData"_qs;
case BitTorrent::TorrentState::Moving:
return QLatin1String("moving");
return u"moving"_qs;
default:
return QLatin1String("unknown");
return u"unknown"_qs;
}
}
}
@@ -128,7 +128,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
{KEY_TORRENT_FIRST_LAST_PIECE_PRIO, torrent.hasFirstLastPiecePriority()},
{KEY_TORRENT_CATEGORY, torrent.category()},
{KEY_TORRENT_TAGS, torrent.tags().join(QLatin1String(", "))},
{KEY_TORRENT_TAGS, torrent.tags().join(u", "_qs)},
{KEY_TORRENT_SUPER_SEEDING, torrent.superSeeding()},
{KEY_TORRENT_FORCE_START, torrent.isForced()},
{KEY_TORRENT_SAVE_PATH, torrent.savePath().toString()},

View File

@@ -140,10 +140,10 @@ namespace
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (sessionStatus.peersCount > 0))
? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue / sessionStatus.peersCount), 2)
: QLatin1String("0");
: u"0"_qs;
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (sessionStatus.peersCount > 0))
? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue / sessionStatus.peersCount), 2)
: QLatin1String("0");
: u"0"_qs;
map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength;
map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime;
@@ -456,8 +456,8 @@ void SyncController::maindataAction()
QVariantMap data;
QVariantMap lastResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastResponse")).toMap();
QVariantMap lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastAcceptedResponse")).toMap();
QVariantMap lastResponse = sessionManager()->session()->getData(u"syncMainDataLastResponse"_qs).toMap();
QVariantMap lastAcceptedResponse = sessionManager()->session()->getData(u"syncMainDataLastAcceptedResponse"_qs).toMap();
QVariantHash torrents;
QHash<QString, QStringList> trackers;
@@ -504,8 +504,8 @@ void SyncController::maindataAction()
const BitTorrent::CategoryOptions categoryOptions = session->categoryOptions(categoryName);
QJsonObject category = categoryOptions.toJSON();
// adjust it to be compatible with exisitng WebAPI
category[QLatin1String("savePath")] = category.take(QLatin1String("save_path"));
category.insert(QLatin1String("name"), categoryName);
category[u"savePath"_qs] = category.take(u"save_path"_qs);
category.insert(u"name"_qs, categoryName);
categories[categoryName] = category.toVariantMap();
}
data[u"categories"_qs] = categories;
@@ -532,8 +532,8 @@ void SyncController::maindataAction()
const int acceptedResponseId {params()[u"rid"_qs].toInt()};
setResult(QJsonObject::fromVariantMap(generateSyncData(acceptedResponseId, data, lastAcceptedResponse, lastResponse)));
sessionManager()->session()->setData(QLatin1String("syncMainDataLastResponse"), lastResponse);
sessionManager()->session()->setData(QLatin1String("syncMainDataLastAcceptedResponse"), lastAcceptedResponse);
sessionManager()->session()->setData(u"syncMainDataLastResponse"_qs, lastResponse);
sessionManager()->session()->setData(u"syncMainDataLastAcceptedResponse"_qs, lastAcceptedResponse);
}
// GET param:
@@ -541,8 +541,8 @@ void SyncController::maindataAction()
// - rid (int): last response id
void SyncController::torrentPeersAction()
{
auto lastResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastResponse")).toMap();
auto lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastAcceptedResponse")).toMap();
auto lastResponse = sessionManager()->session()->getData(u"syncTorrentPeersLastResponse"_qs).toMap();
auto lastAcceptedResponse = sessionManager()->session()->getData(u"syncTorrentPeersLastAcceptedResponse"_qs).toMap();
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
const BitTorrent::Torrent *torrent = BitTorrent::Session::instance()->findTorrent(id);
@@ -585,7 +585,7 @@ void SyncController::torrentPeersAction()
filesForPiece.reserve(filePaths.size());
for (const Path &filePath : filePaths)
filesForPiece.append(filePath.toString());
peer.insert(KEY_PEER_FILES, filesForPiece.join(QLatin1Char('\n')));
peer.insert(KEY_PEER_FILES, filesForPiece.join(u'\n'));
}
if (resolvePeerCountries)
@@ -601,8 +601,8 @@ void SyncController::torrentPeersAction()
const int acceptedResponseId {params()[u"rid"_qs].toInt()};
setResult(QJsonObject::fromVariantMap(generateSyncData(acceptedResponseId, data, lastAcceptedResponse, lastResponse)));
sessionManager()->session()->setData(QLatin1String("syncTorrentPeersLastResponse"), lastResponse);
sessionManager()->session()->setData(QLatin1String("syncTorrentPeersLastAcceptedResponse"), lastAcceptedResponse);
sessionManager()->session()->setData(u"syncTorrentPeersLastResponse"_qs, lastResponse);
sessionManager()->session()->setData(u"syncTorrentPeersLastAcceptedResponse"_qs, lastAcceptedResponse);
}
qint64 SyncController::getFreeDiskSpace()

View File

@@ -123,7 +123,7 @@ namespace
void applyToTorrents(const QStringList &idList, const std::function<void (BitTorrent::Torrent *torrent)> &func)
{
if ((idList.size() == 1) && (idList[0] == QLatin1String("all")))
if ((idList.size() == 1) && (idList[0] == u"all"))
{
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
func(torrent);
@@ -264,8 +264,8 @@ namespace
void TorrentsController::infoAction()
{
const QString filter {params()[u"filter"_qs]};
const std::optional<QString> category = getOptionalString(params(), QLatin1String("category"));
const std::optional<QString> tag = getOptionalString(params(), QLatin1String("tag"));
const std::optional<QString> category = getOptionalString(params(), u"category"_qs);
const std::optional<QString> tag = getOptionalString(params(), u"tag"_qs);
const QString sortedColumn {params()[u"sort"_qs]};
const bool reverse {parseBool(params()[u"reverse"_qs]).value_or(false)};
int limit {params()[u"limit"_qs].toInt()};
@@ -537,7 +537,7 @@ void TorrentsController::filesAction()
const int filesCount = torrent->filesCount();
QVector<int> fileIndexes;
const auto idxIt = params().constFind(QLatin1String("indexes"));
const auto idxIt = params().constFind(u"indexes"_qs);
if (idxIt != params().cend())
{
const QStringList indexStrings = idxIt.value().split(u'|');
@@ -730,9 +730,9 @@ void TorrentsController::addAction()
}
if (partialSuccess)
setResult(QLatin1String("Ok."));
setResult(u"Ok."_qs);
else
setResult(QLatin1String("Fails."));
setResult(u"Fails."_qs);
}
void TorrentsController::addTrackersAction()
@@ -1293,8 +1293,8 @@ void TorrentsController::categoriesAction()
const BitTorrent::CategoryOptions categoryOptions = session->categoryOptions(categoryName);
QJsonObject category = categoryOptions.toJSON();
// adjust it to be compatible with exisitng WebAPI
category[QLatin1String("savePath")] = category.take(QLatin1String("save_path"));
category.insert(QLatin1String("name"), categoryName);
category[u"savePath"_qs] = category.take(u"save_path"_qs);
category.insert(u"name"_qs, categoryName);
categories[categoryName] = category;
}

View File

@@ -71,9 +71,9 @@ void TransferController::infoAction()
dict[KEY_TRANSFER_UPRATELIMIT] = BitTorrent::Session::instance()->uploadSpeedLimit();
dict[KEY_TRANSFER_DHT_NODES] = static_cast<qint64>(sessionStatus.dhtNodes);
if (!BitTorrent::Session::instance()->isListening())
dict[KEY_TRANSFER_CONNECTION_STATUS] = QLatin1String("disconnected");
dict[KEY_TRANSFER_CONNECTION_STATUS] = u"disconnected"_qs;
else
dict[KEY_TRANSFER_CONNECTION_STATUS] = QLatin1String(sessionStatus.hasIncomingConnections ? "connected" : "firewalled");
dict[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections ? u"connected"_qs : u"firewalled"_qs;
setResult(dict);
}

View File

@@ -65,10 +65,10 @@
const int MAX_ALLOWED_FILESIZE = 10 * 1024 * 1024;
const auto C_SID = QByteArrayLiteral("SID"); // name of session id cookie
const QString PATH_PREFIX_ICONS {QStringLiteral("/icons/")};
const QString WWW_FOLDER {QStringLiteral(":/www")};
const QString PUBLIC_FOLDER {QStringLiteral("/public")};
const QString PRIVATE_FOLDER {QStringLiteral("/private")};
const QString PATH_PREFIX_ICONS = u"/icons/"_qs;
const QString WWW_FOLDER = u":/www"_qs;
const QString PUBLIC_FOLDER = u"/public"_qs;
const QString PRIVATE_FOLDER = u"/private"_qs;
namespace
{
@@ -93,8 +93,8 @@ namespace
QUrl urlFromHostHeader(const QString &hostHeader)
{
if (!hostHeader.contains(QLatin1String("://")))
return {QLatin1String("http://") + hostHeader};
if (!hostHeader.contains(u"://"))
return {u"http://"_qs + hostHeader};
return hostHeader;
}
@@ -102,17 +102,17 @@ namespace
{
contentType = contentType.toLower();
if (contentType.startsWith(QLatin1String("image/")))
return QLatin1String("private, max-age=604800"); // 1 week
if (contentType.startsWith(u"image/"))
return u"private, max-age=604800"_qs; // 1 week
if ((contentType == Http::CONTENT_TYPE_CSS)
|| (contentType == Http::CONTENT_TYPE_JS))
{
// short interval in case of program update
return QLatin1String("private, max-age=43200"); // 12 hrs
return u"private, max-age=43200"_qs; // 12 hrs
}
return QLatin1String("no-store");
return u"no-store"_qs;
}
}
@@ -120,16 +120,16 @@ WebApplication::WebApplication(QObject *parent)
: QObject(parent)
, m_cacheID {QString::number(Utils::Random::rand(), 36)}
{
registerAPIController(QLatin1String("app"), new AppController(this, this));
registerAPIController(QLatin1String("auth"), new AuthController(this, this));
registerAPIController(QLatin1String("log"), new LogController(this, this));
registerAPIController(QLatin1String("rss"), new RSSController(this, this));
registerAPIController(QLatin1String("search"), new SearchController(this, this));
registerAPIController(QLatin1String("sync"), new SyncController(this, this));
registerAPIController(QLatin1String("torrents"), new TorrentsController(this, this));
registerAPIController(QLatin1String("transfer"), new TransferController(this, this));
registerAPIController(u"app"_qs, new AppController(this, this));
registerAPIController(u"auth"_qs, new AuthController(this, this));
registerAPIController(u"log"_qs, new LogController(this, this));
registerAPIController(u"rss"_qs, new RSSController(this, this));
registerAPIController(u"search"_qs, new SearchController(this, this));
registerAPIController(u"sync"_qs, new SyncController(this, this));
registerAPIController(u"torrents"_qs, new TorrentsController(this, this));
registerAPIController(u"transfer"_qs, new TransferController(this, this));
declarePublicAPI(QLatin1String("auth/login"));
declarePublicAPI(u"auth/login"_qs);
configure();
connect(Preferences::instance(), &Preferences::changed, this, &WebApplication::configure);
@@ -157,12 +157,9 @@ void WebApplication::sendWebUIFile()
}
}
const QString path
{
(request().path != QLatin1String("/")
? request().path
: QLatin1String("/index.html"))
};
const QString path = (request().path != u"/")
? request().path
: u"/index.html"_qs;
Path localPath = m_rootFolder
/ Path(session() ? PRIVATE_FOLDER : PUBLIC_FOLDER)
@@ -231,8 +228,8 @@ void WebApplication::translateDocument(QString &data) const
found = false; // no more translatable strings
}
data.replace(QLatin1String("${LANG}"), m_currentLocale.left(2));
data.replace(QLatin1String("${CACHEID}"), m_cacheID);
data.replace(u"${LANG}"_qs, m_currentLocale.left(2));
data.replace(u"${CACHEID}"_qs, m_cacheID);
}
}
@@ -260,8 +257,8 @@ void WebApplication::doProcessRequest()
return;
}
const QString action = match.captured(QLatin1String("action"));
const QString scope = match.captured(QLatin1String("scope"));
const QString action = match.captured(u"action"_qs);
const QString scope = match.captured(u"scope"_qs);
APIController *controller = m_apiControllers.value(scope);
if (!controller)
@@ -358,22 +355,22 @@ void WebApplication::configure()
m_isHttpsEnabled = pref->isWebUiHttpsEnabled();
m_prebuiltHeaders.clear();
m_prebuiltHeaders.push_back({Http::HEADER_X_XSS_PROTECTION, QLatin1String("1; mode=block")});
m_prebuiltHeaders.push_back({Http::HEADER_X_CONTENT_TYPE_OPTIONS, QLatin1String("nosniff")});
m_prebuiltHeaders.push_back({Http::HEADER_X_XSS_PROTECTION, u"1; mode=block"_qs});
m_prebuiltHeaders.push_back({Http::HEADER_X_CONTENT_TYPE_OPTIONS, u"nosniff"_qs});
if (!m_isAltUIUsed)
m_prebuiltHeaders.push_back({Http::HEADER_REFERRER_POLICY, QLatin1String("same-origin")});
m_prebuiltHeaders.push_back({Http::HEADER_REFERRER_POLICY, u"same-origin"_qs});
const bool isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled();
if (isClickjackingProtectionEnabled)
m_prebuiltHeaders.push_back({Http::HEADER_X_FRAME_OPTIONS, QLatin1String("SAMEORIGIN")});
m_prebuiltHeaders.push_back({Http::HEADER_X_FRAME_OPTIONS, u"SAMEORIGIN"_qs});
const QString contentSecurityPolicy =
(m_isAltUIUsed
? QLatin1String("")
: QLatin1String("default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none'; form-action 'self';"))
+ (isClickjackingProtectionEnabled ? QLatin1String(" frame-ancestors 'self';") : QLatin1String(""))
+ (m_isHttpsEnabled ? QLatin1String(" upgrade-insecure-requests;") : QLatin1String(""));
? QString()
: u"default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none'; form-action 'self';"_qs)
+ (isClickjackingProtectionEnabled ? u" frame-ancestors 'self';"_qs : QString())
+ (m_isHttpsEnabled ? u" upgrade-insecure-requests;"_qs : QString());
if (!contentSecurityPolicy.isEmpty())
m_prebuiltHeaders.push_back({Http::HEADER_CONTENT_SECURITY_POLICY, contentSecurityPolicy});
@@ -461,7 +458,7 @@ void WebApplication::sendFile(const Path &path)
file.close();
const QMimeType mimeType = QMimeDatabase().mimeTypeForFileNameAndData(path.data(), data);
const bool isTranslatable = mimeType.inherits(QLatin1String("text/plain"));
const bool isTranslatable = mimeType.inherits(u"text/plain"_qs);
// Translate the file
if (isTranslatable)
@@ -533,7 +530,7 @@ void WebApplication::sessionInitialize()
{
Q_ASSERT(!m_currentSession);
const QString sessionId {parseCookie(m_request.headers.value(QLatin1String("cookie"))).value(QString::fromLatin1(C_SID))};
const QString sessionId {parseCookie(m_request.headers.value(u"cookie"_qs)).value(QString::fromLatin1(C_SID))};
// TODO: Additional session check
@@ -590,7 +587,7 @@ bool WebApplication::isAuthNeeded()
bool WebApplication::isPublicAPI(const QString &scope, const QString &action) const
{
return m_publicAPIs.contains(QString::fromLatin1("%1/%2").arg(scope, action));
return m_publicAPIs.contains(u"%1/%2"_qs.arg(scope, action));
}
void WebApplication::sessionStart()
@@ -615,7 +612,7 @@ void WebApplication::sessionStart()
QNetworkCookie cookie(C_SID, m_currentSession->id().toUtf8());
cookie.setHttpOnly(true);
cookie.setSecure(m_isSecureCookieEnabled && m_isHttpsEnabled);
cookie.setPath(QLatin1String("/"));
cookie.setPath(u"/"_qs);
QByteArray cookieRawForm = cookie.toRawForm();
if (m_isCSRFProtectionEnabled)
cookieRawForm.append("; SameSite=Strict");
@@ -627,7 +624,7 @@ void WebApplication::sessionEnd()
Q_ASSERT(m_currentSession);
QNetworkCookie cookie(C_SID);
cookie.setPath(QLatin1String("/"));
cookie.setPath(u"/"_qs);
cookie.setExpirationDate(QDateTime::currentDateTime().addDays(-1));
delete m_sessions.take(m_currentSession->id());

View File

@@ -36,13 +36,14 @@
#include <QSet>
#include <QTranslator>
#include "api/isessionmanager.h"
#include "base/global.h"
#include "base/http/irequesthandler.h"
#include "base/http/responsebuilder.h"
#include "base/http/types.h"
#include "base/path.h"
#include "base/utils/net.h"
#include "base/utils/version.h"
#include "api/isessionmanager.h"
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 9};
@@ -127,7 +128,7 @@ private:
QHash<QString, QString> m_params;
const QString m_cacheID;
const QRegularExpression m_apiPathPattern {QLatin1String("^/api/v2/(?<scope>[A-Za-z_][A-Za-z_0-9]*)/(?<action>[A-Za-z_][A-Za-z_0-9]*)$")};
const QRegularExpression m_apiPathPattern {u"^/api/v2/(?<scope>[A-Za-z_][A-Za-z_0-9]*)/(?<action>[A-Za-z_][A-Za-z_0-9]*)$"_qs};
QHash<QString, APIController *> m_apiControllers;
QSet<QString> m_publicAPIs;