Get rid of QRegExp usage in QFtp
Change-Id: Ia8743467d5b4537fe324a1278b526eb16bf0f732 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
d4a416df2c
commit
6a8132c8ee
@ -47,7 +47,7 @@
|
|||||||
#include "qtcpsocket.h"
|
#include "qtcpsocket.h"
|
||||||
#include "qurlinfo_p.h"
|
#include "qurlinfo_p.h"
|
||||||
#include "qstringlist.h"
|
#include "qstringlist.h"
|
||||||
#include "qregexp.h"
|
#include "qregularexpression.h"
|
||||||
#include "qtimer.h"
|
#include "qtimer.h"
|
||||||
#include "qfileinfo.h"
|
#include "qfileinfo.h"
|
||||||
#include "qtcpserver.h"
|
#include "qtcpserver.h"
|
||||||
@ -621,18 +621,20 @@ bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlIn
|
|||||||
QString bufferStr = QString::fromUtf8(buffer).trimmed();
|
QString bufferStr = QString::fromUtf8(buffer).trimmed();
|
||||||
|
|
||||||
// Unix style FTP servers
|
// Unix style FTP servers
|
||||||
QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+"
|
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.*)"));
|
"(\\S*)\\s+(\\d+)\\s+(\\S+\\s+\\S+\\s+\\S+)\\s+(\\S.*)"));
|
||||||
if (unixPattern.indexIn(bufferStr) == 0) {
|
auto unixPatternMatch = unixPattern.match(bufferStr);
|
||||||
_q_parseUnixDir(unixPattern.capturedTexts(), userName, info);
|
if (unixPatternMatch.hasMatch()) {
|
||||||
|
_q_parseUnixDir(unixPatternMatch.capturedTexts(), userName, info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOS style FTP servers
|
// DOS style FTP servers
|
||||||
QRegExp dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+"
|
QRegularExpression dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+"
|
||||||
"(<DIR>|\\d+)\\s+(\\S.*)$"));
|
"(<DIR>|\\d+)\\s+(\\S.*)$"));
|
||||||
if (dosPattern.indexIn(bufferStr) == 0) {
|
auto dosPatternMatch = dosPattern.match(bufferStr);
|
||||||
_q_parseDosDir(dosPattern.capturedTexts(), userName, info);
|
if (dosPatternMatch.hasMatch()) {
|
||||||
|
_q_parseDosDir(dosPatternMatch.capturedTexts(), userName, info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,14 +1066,15 @@ bool QFtpPI::processReply()
|
|||||||
// both examples where the parenthesis are used, and where
|
// both examples where the parenthesis are used, and where
|
||||||
// they are missing. We need to scan for the address and host
|
// they are missing. We need to scan for the address and host
|
||||||
// info.
|
// info.
|
||||||
QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"));
|
QRegularExpression addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"));
|
||||||
if (addrPortPattern.indexIn(replyText) == -1) {
|
auto addrPortMatch = addrPortPattern.match(replyText);
|
||||||
|
if (!addrPortMatch.hasMatch()) {
|
||||||
#if defined(QFTPPI_DEBUG)
|
#if defined(QFTPPI_DEBUG)
|
||||||
qDebug("QFtp: bad 227 response -- address and port information missing");
|
qDebug("QFtp: bad 227 response -- address and port information missing");
|
||||||
#endif
|
#endif
|
||||||
// this error should be reported
|
// this error should be reported
|
||||||
} else {
|
} else {
|
||||||
const QStringList lst = addrPortPattern.capturedTexts();
|
const QStringList lst = addrPortMatch.capturedTexts();
|
||||||
QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];
|
QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];
|
||||||
quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt();
|
quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt();
|
||||||
waitForDtpToConnect = true;
|
waitForDtpToConnect = true;
|
||||||
|
@ -323,7 +323,7 @@ qt_feature("ftp" PUBLIC
|
|||||||
LABEL "FTP"
|
LABEL "FTP"
|
||||||
PURPOSE "Provides support for the File Transfer Protocol in QNetworkAccessManager."
|
PURPOSE "Provides support for the File Transfer Protocol in QNetworkAccessManager."
|
||||||
AUTODETECT OFF
|
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_definition("ftp" "QT_NO_FTP" NEGATE VALUE "1")
|
||||||
qt_feature("http" PUBLIC
|
qt_feature("http" PUBLIC
|
||||||
|
@ -344,7 +344,7 @@
|
|||||||
"purpose": "Provides support for the File Transfer Protocol in QNetworkAccessManager.",
|
"purpose": "Provides support for the File Transfer Protocol in QNetworkAccessManager.",
|
||||||
"section": "Networking",
|
"section": "Networking",
|
||||||
"autoDetect": false,
|
"autoDetect": false,
|
||||||
"condition": "features.textdate",
|
"condition": "features.textdate && features.regularexpression",
|
||||||
"output": [ "publicFeature", "feature" ]
|
"output": [ "publicFeature", "feature" ]
|
||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user