summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemiterator_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-21 08:31:05 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-02-22 14:00:33 -0800
commit4c1e23c9d3053771c88449025ea332ce723ab665 (patch)
tree65c8a531f7ea89535b98e8473323a2ebb44213c6 /src/corelib/io/qfilesystemiterator_unix.cpp
parent77e00a4d08498285ea4273e01fda489ae6a7fd8a (diff)
QFileSystemIterator/Darwin: enforce NFC encoding in QString
Amends 83f7125ac866ed5a2aaace56ffc866f21f9730b4. We replaced QFile::decodeName() with QStringDecoder so we'd know whether the decoding from UTF-8 had failed, but forgot about Darwin's enforced normalization. Fixes: QTBUG-122624 Change-Id: I01ec3c774d9943adb903fffd17b5edc54c34c067 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Robert Griebl <robert.griebl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/io/qfilesystemiterator_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 30b1a005a9..a1130728ef 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -38,6 +38,14 @@ QFileSystemIterator::~QFileSystemIterator() = default;
bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
{
+ auto asFileEntry = [this](QStringView name) {
+#ifdef Q_OS_DARWIN
+ // must match QFile::decodeName
+ QString normalized = name.toString().normalized(QString::NormalizationForm_C);
+ name = normalized;
+#endif
+ return QFileSystemEntry(dirPath + name, QFileSystemEntry::FromInternalPath());
+ };
if (!dir)
return false;
@@ -62,7 +70,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
auto *end = toUtf16.appendToBuffer(buffer.data(), name);
buffer.resize(end - buffer.constData());
if (!toUtf16.hasError()) {
- fileEntry = {dirPath + QStringView(buffer), QFileSystemEntry::FromInternalPath()};
+ fileEntry = asFileEntry(buffer);
metaData.fillFromDirEnt(*dirEntry);
return true;
} else {