Revert "Make QFile::open fail when using an invalid file name"

This reverts commit 346cd79192. The bug
report was incorrect, since the suggested file name is actually valid,
it just happens to name an Alternate Data Stream (ADS) "20:803Z.txt" in
file "testLog-03".

[ChangeLog][QtCore][QFile] Reverted an incorrect change from Qt 5.9.0
that forbade the creation and access to Alternate Data Streams on NTFS
on Windows. This means that file names containing a colon (':') are
allowed again, but note that they are not regular files.

Task-number: QTBUG-57023
Change-Id: I81480fdb578d4d43b3fcfffd14d4f2147e8a0ade
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
This commit is contained in:
Thiago Macieira 2017-07-26 10:35:55 -07:00
parent 5303225aef
commit 7c45c6a3c4
2 changed files with 0 additions and 15 deletions

View File

@ -108,20 +108,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
{ {
Q_Q(QFSFileEngine); Q_Q(QFSFileEngine);
// Check if the file name is valid:
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
const QString fileName = fileEntry.fileName();
for (QString::const_iterator it = fileName.constBegin(), end = fileName.constEnd();
it != end; ++it) {
const QChar c = *it;
if (c == QLatin1Char('<') || c == QLatin1Char('>') || c == QLatin1Char(':') ||
c == QLatin1Char('\"') || c == QLatin1Char('/') || c == QLatin1Char('\\') ||
c == QLatin1Char('|') || c == QLatin1Char('?') || c == QLatin1Char('*')) {
q->setError(QFile::OpenError, QStringLiteral("Invalid file name"));
return false;
}
}
// All files are opened in share mode (both read and write). // All files are opened in share mode (both read and write).
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;

View File

@ -1155,7 +1155,6 @@ void tst_QFile::invalidFile_data()
#else #else
#if !defined(Q_OS_WINRT) #if !defined(Q_OS_WINRT)
QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid");
QTest::newRow( "date" ) << QString( "testLog-03:20.803Z.txt" );
#endif #endif
QTest::newRow( "colon3" ) << QString( ":failinvalid" ); QTest::newRow( "colon3" ) << QString( ":failinvalid" );
QTest::newRow( "forwardslash" ) << QString( "fail/invalid" ); QTest::newRow( "forwardslash" ) << QString( "fail/invalid" );