Skip to content

Commit

Permalink
Version 5.2.1: Shorten webview socket path.
Browse files Browse the repository at this point in the history
Fixes #28106.
  • Loading branch information
john-preston committed Jul 1, 2024
1 parent dc8c4a8 commit f75429c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Telegram/SourceFiles/platform/linux/specific_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ For license and copyright information please follow this link:
*/
#include "platform/linux/specific_linux.h"

#include "base/openssl_help.h"
#include "base/random.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_dbus_utilities.h"
Expand Down Expand Up @@ -480,6 +481,16 @@ void InstallLauncher() {
});
}

[[nodiscard]] QByteArray HashForSocketPath(const QByteArray &data) {
constexpr auto kHashForSocketPathLength = 24;

const auto binary = openssl::Sha256(bytes::make_span(data));
const auto base64 = QByteArray(
reinterpret_cast<const char*>(binary.data()),
binary.size()).toBase64(QByteArray::Base64UrlEncoding);
return base64.mid(0, kHashForSocketPathLength);
}

} // namespace

namespace Platform {
Expand Down Expand Up @@ -686,8 +697,8 @@ void start() {

Webview::WebKitGTK::SetSocketPath(u"%1/%2-%3-webview-%4"_q.arg(
QDir::tempPath(),
h,
QCoreApplication::applicationName(),
HashForSocketPath(d),
u"TD"_q,//QCoreApplication::applicationName(), - make path smaller.
u"%1"_q).toStdString());

InstallLauncher();
Expand Down

0 comments on commit f75429c

Please sign in to comment.