qCritical() << "Could not open file containing the list of unsynced folders: " << options.unsyncedfolders;
} else {
// filter out empty lines and comments
- selectiveSyncList = QString::fromUtf8(f.readAll()).split('\n').filter(QRegExp("\\S+")).filter(QRegExp("^[^#]"));
+ selectiveSyncList = QString::fromUtf8(f.readAll()).split('\n').filter(QRegularExpression("\\S+")).filter(QRegularExpression("^[^#]"));
for (int i = 0; i < selectiveSyncList.count(); ++i) {
if (!selectiveSyncList.at(i).endsWith(QLatin1Char('/'))) {
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
- QRegExp rx("^GET /\\?code=([a-zA-Z0-9]+)[& ]"); // Match a /?code=... URL
- if (rx.indexIn(peek) != 0) {
+ 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>");
return;
}
- QString code = rx.cap(1); // The 'code' is the first capture of the regexp
+ QString code = rxMatch.captured(1); // The 'code' is the first capture of the regexp
QUrl requestToken = Utility::concatUrlPath(_account->url().toString(), QLatin1String("/index.php/apps/oauth2/api/v1/token"));
QNetworkRequest req;
const QString replyStr = reply()->readAll();
if (replyStr.contains("<?xml version=\"1.0\"?>")) {
- QRegExp rex("<statuscode>(\\d+)</statuscode>");
- if (replyStr.contains(rex)) {
+ const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
+ const auto rexMatch = rex.match(replyStr);
+ if (rexMatch.hasMatch()) {
// this is a error message coming back from ocs.
- replyCode = rex.cap(1).toInt();
+ replyCode = rexMatch.captured(1).toInt();
}
}
emit jobFinished(replyStr, replyCode);
QString ocDir(_sharePath);
ocDir.truncate(ocDir.length() - fileName.length());
- ocDir.replace(QRegExp("^/*"), "");
- ocDir.replace(QRegExp("/*$"), "");
+ ocDir.replace(QRegularExpression("^/*"), "");
+ ocDir.replace(QRegularExpression("/*$"), "");
// Laying this out is complex because sharePath
// may be in use or not.
* for more details.
*/
-#include <QRegExp>
+#include <QRegularExpression>
#include "syncrunfilelog.h"
#include "common/utility.h"
}
QString ts = QString::fromLatin1(item._responseTimeStamp);
if (ts.length() > 6) {
- QRegExp rx(R"((\d\d:\d\d:\d\d))");
- if (ts.contains(rx)) {
- ts = rx.cap(0);
+ const QRegularExpression rx(R"((\d\d:\d\d:\d\d))");
+ const auto rxMatch = rx.match(ts);
+ if (rxMatch.hasMatch()) {
+ ts = rxMatch.captured(0);
}
}
*/
#include <QList>
-#include <QRegExp>
#include <QString>
#include <QSslCertificate>
#include <QSslConfiguration>
// FIXME: move to ExcludedFiles 's regexp ?
bool isInvalidPattern = false;
- if (excluded == CSYNC_NOT_EXCLUDED && !_discoveryData->_invalidFilenameRx.isEmpty()) {
+ if (excluded == CSYNC_NOT_EXCLUDED && !_discoveryData->_invalidFilenameRx.pattern().isEmpty()) {
if (path.contains(_discoveryData->_invalidFilenameRx)) {
excluded = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
isInvalidPattern = true;
AccountPtr _account;
SyncOptions _syncOptions;
ExcludedFiles *_excludes;
- QRegExp _invalidFilenameRx; // FIXME: maybe move in ExcludedFiles
+ QRegularExpression _invalidFilenameRx; // FIXME: maybe move in ExcludedFiles
QStringList _serverBlacklistedFiles; // The blacklist from the capabilities
bool _ignoreHiddenFiles = false;
std::function<bool(const QString &)> _shouldDiscoverLocaly;
#include "config.h"
#include <QDir>
+#include <QRegularExpression>
#include <QStringList>
#include <QtGlobal>
#include <QTextCodec>
// Expire old log files and deal with conflicts
QStringList files = dir.entryList(QStringList("*owncloud.log.*"),
QDir::Files, QDir::Name);
- QRegExp rx(R"(.*owncloud\.log\.(\d+).*)");
+ const QRegularExpression rx(QRegularExpression::anchoredPattern(R"(.*owncloud\.log\.(\d+).*)"));
int maxNumber = -1;
foreach (const QString &s, files) {
if (_logExpire > 0) {
dir.remove(s);
}
}
- if (s.startsWith(newLogName) && rx.exactMatch(s)) {
- maxNumber = qMax(maxNumber, rx.cap(1).toInt());
+ const auto rxMatch = rx.match(s);
+ if (s.startsWith(newLogName) && rxMatch.hasMatch()) {
+ maxNumber = qMax(maxNumber, rxMatch.captured(1).toInt());
}
}
newLogName.append("." + QString::number(maxNumber + 1));
QString jsonStr = QString::fromUtf8(reply()->readAll());
if (jsonStr.contains("<?xml version=\"1.0\"?>")) {
- QRegExp rex("<statuscode>(\\d+)</statuscode>");
- if (jsonStr.contains(rex)) {
+ const QRegularExpression rex("<statuscode>(\\d+)</statuscode>");
+ const auto rexMatch = rex.match(jsonStr);
+ if (rexMatch.hasMatch()) {
// this is a error message coming back from ocs.
- statusCode = rex.cap(1).toInt();
+ statusCode = rexMatch.captured(1).toInt();
}
} else if(jsonStr.isEmpty() && httpStatusCode == notModifiedStatusCode){
qCWarning(lcJsonApiJob) << "Nothing changed so nothing to retrieve - status code: " << httpStatusCode;
statusCode = httpStatusCode;
} else {
- QRegExp rex(R"("statuscode":(\d+))");
+ const QRegularExpression rex(R"("statuscode":(\d+))");
// example: "{"ocs":{"meta":{"status":"ok","statuscode":100,"message":null},"data":{"version":{"major":8,"minor":"... (504)
- if (jsonStr.contains(rex)) {
- statusCode = rex.cap(1).toInt();
+ const auto rxMatch = rex.match(jsonStr);
+ if (rxMatch.hasMatch()) {
+ statusCode = rxMatch.captured(1).toInt();
}
}
qint64 start = 0;
QByteArray ranges = reply()->rawHeader("Content-Range");
if (!ranges.isEmpty()) {
- QRegExp rx("bytes (\\d+)-");
- if (rx.indexIn(ranges) >= 0) {
- start = rx.cap(1).toLongLong();
+ const QRegularExpression rx("bytes (\\d+)-");
+ const auto rxMatch = rx.match(ranges);
+ if (rxMatch.hasMatch()) {
+ start = rxMatch.captured(1).toLongLong();
}
}
if (start != _resumeStart) {
invalidFilenamePattern = R"([\\:?*"<>|])";
}
if (!invalidFilenamePattern.isEmpty())
- _discoveryPhase->_invalidFilenameRx = QRegExp(invalidFilenamePattern);
+ _discoveryPhase->_invalidFilenameRx = QRegularExpression(invalidFilenamePattern);
_discoveryPhase->_serverBlacklistedFiles = _account->capabilities().blacklistedFiles();
_discoveryPhase->_ignoreHiddenFiles = ignoreHiddenFiles();
const QString script = qEnvironmentVariable("OWNCLOUD_POST_UPDATE_SCRIPT");
qCDebug(lcEngine) << "Post Update Script: " << script;
- auto scriptArgs = script.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
+ auto scriptArgs = script.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
if (scriptArgs.size() > 0) {
const auto scriptExecutable = scriptArgs.takeFirst();
QProcess::execute(scriptExecutable, scriptArgs);
{
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket->canReadLine()) {
- QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
+ QStringList tokens = QString(socket->readLine()).split(QRegularExpression("[ \r\n][ \r\n]*"));
if (tokens[0] == "GET") {
QTextStream os(socket);
os.setAutoDetectUnicode(true);
qDebug() << "Version of installed Nextcloud: " << ver;
QVERIFY(!ver.isEmpty());
- QRegExp rx(APPLICATION_SHORTNAME R"( version \d+\.\d+\.\d+.*)");
- QVERIFY(rx.exactMatch(ver));
+ const QRegularExpression rx(QRegularExpression::anchoredPattern(APPLICATION_SHORTNAME R"( version \d+\.\d+\.\d+.*)"));
+ QVERIFY(rx.match(ver).hasMatch());
} else {
QVERIFY(versionOfInstalledBinary().isEmpty());
}