From: Claudio Cambra Date: Mon, 19 Dec 2022 16:26:15 +0000 (+0100) Subject: Declare all QRegularExpressions statically X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~51^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ce57d3b3ab804508baa5d888d0c061d8d35d9884;p=nextcloud-desktop.git Declare all QRegularExpressions statically Signed-off-by: Claudio Cambra --- diff --git a/src/gui/creds/oauth.cpp b/src/gui/creds/oauth.cpp index 39534fa48..04b0e62f8 100644 --- a/src/gui/creds/oauth.cpp +++ b/src/gui/creds/oauth.cpp @@ -70,7 +70,7 @@ void OAuth::start() QByteArray peek = socket->peek(qMin(socket->bytesAvailable(), 4000LL)); //The code should always be within the first 4K if (peek.indexOf('\n') < 0) return; // wait until we find a \n - const QRegularExpression rx("^GET /\\?code=([a-zA-Z0-9]+)[& ]"); // Match a /?code=... URL + static const QRegularExpression rx("^GET /\\?code=([a-zA-Z0-9]+)[& ]"); // Match a /?code=... URL const auto rxMatch = rx.match(peek); if (!rxMatch.hasMatch()) { httpReplyAndClose(socket, "404 Not Found", "404 Not Found

404 Not Found

"); diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index 5e1b2837c..fc18fddd4 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -319,7 +319,7 @@ bool EditLocallyJob::isTokenValid(const QString &token) // Token is an alphanumeric string 128 chars long. // Ensure that is what we received and what we are sending to the server. - const QRegularExpression tokenRegex("^[a-zA-Z0-9]{128}$"); + static const QRegularExpression tokenRegex("^[a-zA-Z0-9]{128}$"); const auto regexMatch = tokenRegex.match(token); return regexMatch.hasMatch(); diff --git a/src/gui/notificationconfirmjob.cpp b/src/gui/notificationconfirmjob.cpp index 09e147da3..8071aefdd 100644 --- a/src/gui/notificationconfirmjob.cpp +++ b/src/gui/notificationconfirmjob.cpp @@ -56,7 +56,7 @@ bool NotificationConfirmJob::finished() const QString replyStr = reply()->readAll(); if (replyStr.contains("")) { - const QRegularExpression rex("(\\d+)"); + static const QRegularExpression rex("(\\d+)"); const auto rexMatch = rex.match(replyStr); if (rexMatch.hasMatch()) { // this is a error message coming back from ocs. diff --git a/src/gui/syncrunfilelog.cpp b/src/gui/syncrunfilelog.cpp index 6f75f53ce..f04636b4f 100644 --- a/src/gui/syncrunfilelog.cpp +++ b/src/gui/syncrunfilelog.cpp @@ -104,7 +104,7 @@ void SyncRunFileLog::logItem(const SyncFileItem &item) } QString ts = QString::fromLatin1(item._responseTimeStamp); if (ts.length() > 6) { - const QRegularExpression rx(R"((\d\d:\d\d:\d\d))"); + static const QRegularExpression rx(R"((\d\d:\d\d:\d\d))"); const auto rxMatch = rx.match(ts); if (rxMatch.hasMatch()) { ts = rxMatch.captured(0); diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 608771748..f6c95e375 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -306,7 +306,7 @@ void Logger::enterNextLogFile() // Expire old log files and deal with conflicts QStringList files = dir.entryList(QStringList("*owncloud.log.*"), QDir::Files, QDir::Name) + dir.entryList(QStringList("*nextcloud.log.*"), QDir::Files, QDir::Name); - const QRegularExpression rx(QRegularExpression::anchoredPattern(R"(.*(next|own)cloud\.log\.(\d+).*)")); + static const QRegularExpression rx(QRegularExpression::anchoredPattern(R"(.*(next|own)cloud\.log\.(\d+).*)")); int maxNumber = -1; foreach (const QString &s, files) { if (_logExpire > 0) { diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index dd26a9550..19951674d 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -840,7 +840,7 @@ bool JsonApiJob::finished() QString jsonStr = QString::fromUtf8(reply()->readAll()); if (jsonStr.contains("")) { - const QRegularExpression rex("(\\d+)"); + static const QRegularExpression rex("(\\d+)"); const auto rexMatch = rex.match(jsonStr); if (rexMatch.hasMatch()) { // this is a error message coming back from ocs. @@ -850,7 +850,7 @@ bool JsonApiJob::finished() qCWarning(lcJsonApiJob) << "Nothing changed so nothing to retrieve - status code: " << httpStatusCode; statusCode = httpStatusCode; } else { - const QRegularExpression rex(R"("statuscode":(\d+))"); + static const QRegularExpression rex(R"("statuscode":(\d+))"); // example: "{"ocs":{"meta":{"status":"ok","statuscode":100,"message":null},"data":{"version":{"major":8,"minor":"... (504) const auto rxMatch = rex.match(jsonStr); if (rxMatch.hasMatch()) { diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 0bb179b81..b390cee55 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -219,7 +219,7 @@ void GETFileJob::slotMetaDataChanged() qint64 start = 0; QByteArray ranges = reply()->rawHeader("Content-Range"); if (!ranges.isEmpty()) { - const QRegularExpression rx("bytes (\\d+)-"); + static const QRegularExpression rx("bytes (\\d+)-"); const auto rxMatch = rx.match(ranges); if (rxMatch.hasMatch()) { start = rxMatch.captured(1).toLongLong(); diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index e9d3206c9..0a4b62820 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -813,7 +813,8 @@ void Theme::replaceLinkColorStringBackgroundAware(QString &linkString) void Theme::replaceLinkColorString(QString &linkString, const QColor &newColor) { - linkString.replace(QRegularExpression("(