More Fixes
This commit is contained in:
+7
-3
@@ -42,6 +42,7 @@
|
||||
// #include <KConfigGroup>
|
||||
// #include <KSharedConfig>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#if defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_MAC)
|
||||
#include <sys/sysctl.h>
|
||||
@@ -1133,16 +1134,19 @@ QString SSHProcessInfo::format(const QString& input) const
|
||||
QString output(input);
|
||||
|
||||
// test whether host is an ip address
|
||||
// in which case 'short host' and 'full host'
|
||||
// markers in the input string are replaced with
|
||||
// the full address
|
||||
bool isIpAddress = false;
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
struct in_addr address;
|
||||
if (inet_aton(_host.toLocal8Bit().constData(), &address) != 0)
|
||||
isIpAddress = true;
|
||||
else
|
||||
isIpAddress = false;
|
||||
#else
|
||||
// On Windows, use a simple heuristic: contains only digits and dots → IP
|
||||
isIpAddress = QRegularExpression(QStringLiteral("^\\d+\\.\\d+\\.\\d+\\.\\d+$"))
|
||||
.match(_host).hasMatch();
|
||||
#endif
|
||||
|
||||
// search for and replace known markers
|
||||
output.replace("%u", _user);
|
||||
|
||||
Reference in New Issue
Block a user