From 78c90fe7c6c7d9de2d6352c5a30b3ff786c1be5a Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 7 Nov 2025 20:39:34 -0500 Subject: [PATCH] fix: Crash caused by hostnames with invalid characters returned by machine name. fixes: #9006 Only cleans the hostname if the system is using the default Replace Spaces with _ Remove any other non word characters --- src/lib/common/Settings.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 105d77d14..126feab6b 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -11,6 +11,7 @@ #include #include #include +#include Settings *Settings::instance() { @@ -117,8 +118,13 @@ QVariant Settings::defaultValue(const QString &key) return true; } - if (key == Core::ScreenName) - return QSysInfo::machineHostName(); + if (key == Core::ScreenName) { + // The localhost name can contain spaces and non word characters + QString name = QSysInfo::machineHostName().simplified(); + name.replace(QLatin1String(" "), QStringLiteral("_")); + name.replace(QRegularExpression(QLatin1String("\\W")), QLatin1String("")); + return name; + } if (key == Gui::WindowGeometry) return QRect();