diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 2589c64b1c4..e1b99c4599b 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -47,7 +47,7 @@ #include "qtcpsocket.h" #include "qurlinfo_p.h" #include "qstringlist.h" -#include "qregexp.h" +#include "qregularexpression.h" #include "qtimer.h" #include "qfileinfo.h" #include "qtcpserver.h" @@ -621,18 +621,20 @@ bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlIn QString bufferStr = QString::fromUtf8(buffer).trimmed(); // Unix style FTP servers - QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+" - "(\\S*)\\s+(\\d+)\\s+(\\S+\\s+\\S+\\s+\\S+)\\s+(\\S.*)")); - if (unixPattern.indexIn(bufferStr) == 0) { - _q_parseUnixDir(unixPattern.capturedTexts(), userName, info); + QRegularExpression unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+" + "(\\S*)\\s+(\\d+)\\s+(\\S+\\s+\\S+\\s+\\S+)\\s+(\\S.*)")); + auto unixPatternMatch = unixPattern.match(bufferStr); + if (unixPatternMatch.hasMatch()) { + _q_parseUnixDir(unixPatternMatch.capturedTexts(), userName, info); return true; } // DOS style FTP servers - QRegExp dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+" - "(|\\d+)\\s+(\\S.*)$")); - if (dosPattern.indexIn(bufferStr) == 0) { - _q_parseDosDir(dosPattern.capturedTexts(), userName, info); + QRegularExpression dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+" + "(|\\d+)\\s+(\\S.*)$")); + auto dosPatternMatch = dosPattern.match(bufferStr); + if (dosPatternMatch.hasMatch()) { + _q_parseDosDir(dosPatternMatch.capturedTexts(), userName, info); return true; } @@ -1064,14 +1066,15 @@ bool QFtpPI::processReply() // both examples where the parenthesis are used, and where // they are missing. We need to scan for the address and host // info. - QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)")); - if (addrPortPattern.indexIn(replyText) == -1) { + QRegularExpression addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)")); + auto addrPortMatch = addrPortPattern.match(replyText); + if (!addrPortMatch.hasMatch()) { #if defined(QFTPPI_DEBUG) qDebug("QFtp: bad 227 response -- address and port information missing"); #endif // this error should be reported } else { - const QStringList lst = addrPortPattern.capturedTexts(); + const QStringList lst = addrPortMatch.capturedTexts(); QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4]; quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt(); waitForDtpToConnect = true; diff --git a/src/network/configure.cmake b/src/network/configure.cmake index e4699b7213b..d9b47045aee 100644 --- a/src/network/configure.cmake +++ b/src/network/configure.cmake @@ -323,7 +323,7 @@ qt_feature("ftp" PUBLIC LABEL "FTP" PURPOSE "Provides support for the File Transfer Protocol in QNetworkAccessManager." AUTODETECT OFF - CONDITION QT_FEATURE_textdate + CONDITION QT_FEATURE_textdate AND QT_FEATURE_regularexpression ) qt_feature_definition("ftp" "QT_NO_FTP" NEGATE VALUE "1") qt_feature("http" PUBLIC diff --git a/src/network/configure.json b/src/network/configure.json index d6be41128ac..84ad6cc4e8a 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -344,7 +344,7 @@ "purpose": "Provides support for the File Transfer Protocol in QNetworkAccessManager.", "section": "Networking", "autoDetect": false, - "condition": "features.textdate", + "condition": "features.textdate && features.regularexpression", "output": [ "publicFeature", "feature" ] }, "http": {