take prefix into account and use HEX string in QSharedMemoryPrivate::makePlatformSafeKey()

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-12-24 05:53:06 +00:00
parent 3643bf444e
commit 3c70205ac0

View file

@ -35,7 +35,6 @@
#include "qsharedmemory_p.h" #include "qsharedmemory_p.h"
#include "qsystemsemaphore.h" #include "qsystemsemaphore.h"
#include "qdir.h" #include "qdir.h"
#include "qcryptographichash.h"
#include "qdebug.h" #include "qdebug.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -55,11 +54,7 @@ QString QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
if (key.isEmpty()) if (key.isEmpty())
return QString(); return QString();
QString part1 = key; QString result = prefix + key.toUtf8().toHex();
part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex();
QString result = (part1 + QString::fromLatin1(hex.constData()));
#if defined(QT_POSIX_IPC) #if defined(QT_POSIX_IPC)
return QLatin1Char('/') + result; return QLatin1Char('/') + result;
#else #else