QFtp: Use UTF-8 encoding.
According to RFC 2640, FTP uses UTF-8 encoding. Fix the conversions accordingly. Task-number: QTBUG-52303 Change-Id: I615199b3d074fc3861f25df113dda672525766b6 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
3ddb2c325e
commit
d37239aa41
@ -611,7 +611,7 @@ bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlIn
|
|||||||
if (buffer.isEmpty())
|
if (buffer.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString bufferStr = QString::fromLatin1(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+"
|
QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+"
|
||||||
@ -676,7 +676,7 @@ void QFtpDTP::socketReadyRead()
|
|||||||
// does not exist, but rather write a text to the data socket
|
// does not exist, but rather write a text to the data socket
|
||||||
// -- try to catch these cases
|
// -- try to catch these cases
|
||||||
if (line.endsWith("No such file or directory\r\n"))
|
if (line.endsWith("No such file or directory\r\n"))
|
||||||
err = QString::fromLatin1(line);
|
err = QString::fromUtf8(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -932,7 +932,7 @@ void QFtpPI::readyRead()
|
|||||||
|
|
||||||
while (commandSocket.canReadLine()) {
|
while (commandSocket.canReadLine()) {
|
||||||
// read line with respect to line continuation
|
// read line with respect to line continuation
|
||||||
QString line = QString::fromLatin1(commandSocket.readLine());
|
QString line = QString::fromUtf8(commandSocket.readLine());
|
||||||
if (replyText.isEmpty()) {
|
if (replyText.isEmpty()) {
|
||||||
if (line.length() < 3) {
|
if (line.length() < 3) {
|
||||||
// protocol error
|
// protocol error
|
||||||
@ -964,7 +964,7 @@ void QFtpPI::readyRead()
|
|||||||
replyText += line;
|
replyText += line;
|
||||||
if (!commandSocket.canReadLine())
|
if (!commandSocket.canReadLine())
|
||||||
return;
|
return;
|
||||||
line = QString::fromLatin1(commandSocket.readLine());
|
line = QString::fromUtf8(commandSocket.readLine());
|
||||||
lineLeft4 = line.left(4);
|
lineLeft4 = line.left(4);
|
||||||
}
|
}
|
||||||
replyText += line.mid(4); // strip reply code 'xyz '
|
replyText += line.mid(4); // strip reply code 'xyz '
|
||||||
@ -1215,7 +1215,7 @@ bool QFtpPI::startNextCmd()
|
|||||||
qDebug("QFtpPI send: %s", currentCmd.left(currentCmd.length()-2).toLatin1().constData());
|
qDebug("QFtpPI send: %s", currentCmd.left(currentCmd.length()-2).toLatin1().constData());
|
||||||
#endif
|
#endif
|
||||||
state = Waiting;
|
state = Waiting;
|
||||||
commandSocket.write(currentCmd.toLatin1());
|
commandSocket.write(currentCmd.toUtf8());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,10 +732,11 @@ void tst_QFtp::put_data()
|
|||||||
QByteArray bigData( 10*1024*1024, 0 );
|
QByteArray bigData( 10*1024*1024, 0 );
|
||||||
bigData.fill( 'A' );
|
bigData.fill( 'A' );
|
||||||
|
|
||||||
// test the two put() overloads in one routine
|
// test the two put() overloads in one routine with a file name containing
|
||||||
|
// U+0x00FC (latin small letter u with diaeresis) for QTBUG-52303, testing UTF-8
|
||||||
for ( int i=0; i<2; i++ ) {
|
for ( int i=0; i<2; i++ ) {
|
||||||
QTest::newRow( QString("relPath01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString()
|
QTest::newRow( QString("relPath01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString()
|
||||||
<< QString("qtest/upload/rel01_%1") << rfc3252
|
<< (QLatin1String("qtest/upload/rel01_") + QChar(0xfc) + QLatin1String("%1")) << rfc3252
|
||||||
<< (bool)(i==1) << 1;
|
<< (bool)(i==1) << 1;
|
||||||
/*
|
/*
|
||||||
QTest::newRow( QString("relPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password")
|
QTest::newRow( QString("relPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user