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", "<html><head><title>404 Not Found</title></head><body><center><h1>404 Not Found</h1></center></body></html>");
// 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();
const QString replyStr = reply()->readAll();
if (replyStr.contains("<?xml version=\"1.0\"?>")) {
- const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
+ static const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
const auto rexMatch = rex.match(replyStr);
if (rexMatch.hasMatch()) {
// this is a error message coming back from ocs.
}
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);
// 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) {
QString jsonStr = QString::fromUtf8(reply()->readAll());
if (jsonStr.contains("<?xml version=\"1.0\"?>")) {
- const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
+ static const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
const auto rexMatch = rex.match(jsonStr);
if (rexMatch.hasMatch()) {
// this is a error message coming back from ocs.
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()) {
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();
void Theme::replaceLinkColorString(QString &linkString, const QColor &newColor)
{
- linkString.replace(QRegularExpression("(<a href|<a style='color:#([a-zA-Z0-9]{6});' href)"), QString::fromLatin1("<a style='color:%1;' href").arg(newColor.name()));
+ static const QRegularExpression linkRegularExpression("(<a href|<a style='color:#([a-zA-Z0-9]{6});' href)");
+ linkString.replace(linkRegularExpression, QString::fromLatin1("<a style='color:%1;' href").arg(newColor.name()));
}
QIcon Theme::createColorAwareIcon(const QString &name, const QPalette &palette)