QFileSystemIterator/Darwin: enforce NFC encoding in QString
Amends 83f7125ac8. 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>
bb10
parent
77e00a4d08
commit
4c1e23c9d3
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue