diff options
-rw-r--r-- | src/corelib/kernel/qsharedmemory.cpp | 8 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index c8ba13c90c..c952655cb8 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -67,9 +67,11 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, QString result = prefix; - QString part1 = key; - part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString()); - result.append(part1); + for (QChar ch : key) { + if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) || + (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))) + result += ch; + } QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex(); result.append(QLatin1String(hex)); diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index 3b25000b22..f81324b894 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -815,6 +815,7 @@ void tst_QSharedMemory::uniqueKey_data() QTest::newRow("key != key1") << QString("key") << QString("key1"); QTest::newRow("ke1y != key1") << QString("ke1y") << QString("key1"); QTest::newRow("key1 != key2") << QString("key1") << QString("key2"); + QTest::newRow("Noël -> Nol") << QString::fromUtf8("N\xc3\xabl") << QString("Nol"); } void tst_QSharedMemory::uniqueKey() |