fix(cpn): radio specific name and label validators (#4670)
Only allows valid characters in names, drops invalid characters if present
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
|
||||
#include "yaml_ops.h"
|
||||
#include "labelvalidator.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
SemanticVersion radioSettingsVersion;
|
||||
SemanticVersion modelSettingsVersion;
|
||||
@@ -57,6 +59,32 @@ void operator >> (const YAML::Node& node, bool& value)
|
||||
}
|
||||
}
|
||||
|
||||
void YamlValidateLabel(QString &input)
|
||||
{
|
||||
LabelValidator *lv = new LabelValidator();
|
||||
|
||||
if (!lv->isValid(input)) {
|
||||
lv->fixup(input);
|
||||
input = input.trimmed();
|
||||
}
|
||||
|
||||
delete lv;
|
||||
}
|
||||
|
||||
void YamlValidateName(char *input, Board::Type board)
|
||||
{
|
||||
NameValidator *nv = new NameValidator(board);
|
||||
QString in(input);
|
||||
|
||||
if (!nv->isValid(in)) {
|
||||
nv->fixup(in);
|
||||
in = in.trimmed();
|
||||
}
|
||||
|
||||
strcpy(input, in.toLatin1().data());
|
||||
delete nv;
|
||||
}
|
||||
|
||||
namespace YAML {
|
||||
|
||||
std::string LookupValue(const YamlLookupTable& lut, const int& value)
|
||||
|
||||
Reference in New Issue
Block a user