diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-06 11:24:38 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-21 07:49:00 +0000 |
commit | 49d3bb005889b9fb5a06d6aadac23ebd5b2f9f2d (patch) | |
tree | 281ff7de89ec8cad24b173ef46e8c61dc920ab83 | |
parent | 557abfc3275f74d3dd537d7bca86e15860d072e9 (diff) |
Normalize realpath(3) output to composed form
All strings coming out of POSIX API calls are converted to composed form
by QFile::decodeName. Do the same for realpath(3) output. This is
especially important for HFS+, which will store file names in decomposed
form, and APIs will therefore return strings in decomposed form.
Task-number: QTBUG-55896
Change-Id: I5e51f4e5712ff26bf9644cbcf9a9603995748892
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 7bc2293b0d..3cc27bf847 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -276,7 +276,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, if (ret) { data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; data.entryFlags |= QFileSystemMetaData::ExistsAttribute; - QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); + QString canonicalPath = QDir::cleanPath(QFile::decodeName(ret)); free(ret); return QFileSystemEntry(canonicalPath); } else if (errno == ENOENT) { // file doesn't exist diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index d2c43f79d6..10921ea0a3 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -770,6 +770,19 @@ void tst_QFileInfo::canonicalFilePath() QDir::current().rmdir(linkTarget); } #endif + +#ifdef Q_OS_DARWIN + { + // Check if canonicalFilePath's result is in Composed normalization form. + QString path = QString::fromLatin1("caf\xe9"); + QDir dir(QDir::tempPath()); + dir.mkdir(path); + QString canonical = QFileInfo(dir.filePath(path)).canonicalFilePath(); + QString roundtrip = QFile::decodeName(QFile::encodeName(canonical)); + QCOMPARE(canonical, roundtrip); + dir.rmdir(path); + } +#endif } void tst_QFileInfo::fileName_data() |