diff options
Diffstat (limited to 'src/network/access/qftp.cpp')
-rw-r--r-- | src/network/access/qftp.cpp | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 2589c64b1c..048c272780 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" @@ -317,10 +317,6 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) socket = nullptr; } socket = new QTcpSocket(this); -#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section - //copy network session down to the socket - socket->setProperty("_q_networksession", property("_q_networksession")); -#endif socket->setObjectName(QLatin1String("QFtpDTP Passive state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); @@ -333,10 +329,6 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) int QFtpDTP::setupListener(const QHostAddress &address) { -#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section - //copy network session down to the socket - listener.setProperty("_q_networksession", property("_q_networksession")); -#endif if (!listener.isListening() && !listener.listen(address, 0)) return -1; return listener.serverPort(); @@ -621,18 +613,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+" - "(<DIR>|\\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+" + "(<DIR>|\\d+)\\s+(\\S.*)$")); + auto dosPatternMatch = dosPattern.match(bufferStr); + if (dosPatternMatch.hasMatch()) { + _q_parseDosDir(dosPatternMatch.capturedTexts(), userName, info); return true; } @@ -817,11 +811,6 @@ QFtpPI::QFtpPI(QObject *parent) : void QFtpPI::connectToHost(const QString &host, quint16 port) { emit connectState(QFtp::HostLookup); -#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section - //copy network session down to the socket & DTP - commandSocket.setProperty("_q_networksession", property("_q_networksession")); - dtp.setProperty("_q_networksession", property("_q_networksession")); -#endif commandSocket.connectToHost(host, port); } @@ -1064,14 +1053,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; @@ -2287,10 +2277,6 @@ void QFtpPrivate::_q_startNextCommand() c->rawCmds.clear(); _q_piFinished(QLatin1String("Proxy set to ") + proxyHost + QLatin1Char(':') + QString::number(proxyPort)); } else if (c->command == QFtp::ConnectToHost) { -#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section - //copy network session down to the PI - pi.setProperty("_q_networksession", q->property("_q_networksession")); -#endif if (!proxyHost.isEmpty()) { host = c->rawCmds.at(0); port = c->rawCmds.at(1).toUInt(); |