aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp')
-rw-r--r--share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp b/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp
index cbc5635ad0..a685b9fd40 100644
--- a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp
+++ b/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp
@@ -53,6 +53,14 @@
#define NAME_MAX PSHMNAMLEN
#endif
+#ifndef QStringLiteral
+#define QStringLiteral(str) QString::fromUtf8(str)
+#endif
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
+#include <QRegExp>
+#endif
+
namespace QmlDesigner {
class SharedMemoryLocker
@@ -94,8 +102,17 @@ static QByteArray makePlatformSafeKey(const QString &key)
{
if (key.isEmpty())
return QByteArray();
+#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
+ QByteArray data(QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64());
+ QString ambiguousChars(QStringLiteral("[=~<>|?*!@#$%^&:,; \\\\]"));
+
+ QByteArray normalizedData;
+ normalizedData = QString(data).replace(QRegExp(ambiguousChars), QStringLiteral("_")).toLatin1();
+ return normalizedData;
+#else
return QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
+#endif
}