Remove use of QRegExp from QSharedMemory

This patch updates the code from QSharedMemory to remove the use
of the deprecated QRegExp class. It also updates the unique key
test to avoid change of behavior going undetected.

Change-Id: I649e615027507898800bb5454a62a6cf8bbb2e18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Samuel Gaist 2017-01-30 00:04:08 +01:00
parent 83aca24bc4
commit 2b0eb3fac3
2 changed files with 6 additions and 3 deletions

View File

@ -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));

View File

@ -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()