fix: screensettingsDialog, do not allow aliases to be ip addresses
fixes: #8952
This commit is contained in:
@ -110,6 +110,8 @@ add_library(${target} STATIC
|
||||
validators/SpacesValidator.h
|
||||
validators/ValidationError.cpp
|
||||
validators/ValidationError.h
|
||||
validators/IpAddressValidator.cpp
|
||||
validators/IpAddressValidator.h
|
||||
widgets/FingerprintPreview.cpp
|
||||
widgets/FingerprintPreview.h
|
||||
widgets/KeySequenceWidget.cpp
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "AliasValidator.h"
|
||||
|
||||
#include "ComputerNameValidator.h"
|
||||
#include "IpAddressValidator.h"
|
||||
#include "SpacesValidator.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
@ -16,6 +17,7 @@ namespace validators {
|
||||
AliasValidator::AliasValidator(QLineEdit *parent, ValidationError *error) : LineEditValidator(parent, error)
|
||||
{
|
||||
addValidator(std::make_unique<SpacesValidator>("Computer name cannot contain spaces"));
|
||||
addValidator(std::make_unique<IpAddressValidator>("Aliases may not be ip addresses"));
|
||||
addValidator(std::make_unique<ComputerNameValidator>("Contains invalid characters or is too long"));
|
||||
}
|
||||
|
||||
|
||||
25
src/lib/gui/validators/IpAddressValidator.cpp
Normal file
25
src/lib/gui/validators/IpAddressValidator.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "IpAddressValidator.h"
|
||||
|
||||
namespace validators {
|
||||
|
||||
IpAddressValidator::IpAddressValidator(const QString &message) : IStringValidator(message)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
bool IpAddressValidator::validate(const QString &input) const
|
||||
{
|
||||
static const auto sIpRegex = QRegularExpression(
|
||||
R"((\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})"
|
||||
);
|
||||
const auto match = sIpRegex.match(input);
|
||||
return !match.hasMatch();
|
||||
}
|
||||
|
||||
} // namespace validators
|
||||
21
src/lib/gui/validators/IpAddressValidator.h
Normal file
21
src/lib/gui/validators/IpAddressValidator.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IStringValidator.h"
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace validators {
|
||||
|
||||
class IpAddressValidator : public IStringValidator
|
||||
{
|
||||
public:
|
||||
explicit IpAddressValidator(const QString &message);
|
||||
bool validate(const QString &input) const override;
|
||||
};
|
||||
|
||||
} // namespace validators
|
||||
Reference in New Issue
Block a user