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 "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+"
|
||||
"(<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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user