2020-08-10 Fred Gleason <fredg@paravelsystems.com>

* Added a check in 'RDSvc::create()' to disallow creation of a
	service with a name containing whitespace.
	* Added whitespace to the set of banned characters for service names
	in the 'Add Service' dialog in rdadmin(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2020-08-10 13:17:27 -04:00
parent d4f76649e8
commit d433e3c631
12 changed files with 56 additions and 10 deletions

View File

@ -19941,3 +19941,8 @@
'ripcd/local_macros.cpp'.
2020-08-10 Fred Gleason <fredg@paravelsystems.com>
* Documented the '%%' filepath wildcard in the Operations Guide.
2020-08-10 Fred Gleason <fredg@paravelsystems.com>
* Added a check in 'RDSvc::create()' to disallow creation of a
service with a name containing whitespace.
* Added whitespace to the set of banned characters for service names
in the 'Add Service' dialog in rdadmin(1).

View File

@ -809,6 +809,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -805,6 +805,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -805,6 +805,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -775,6 +775,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -805,6 +805,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -805,6 +805,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -805,6 +805,10 @@
<source>Results Report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>whitespace is not permitted in service names</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -2,7 +2,7 @@
//
// Abstract a Rivendell Service.
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -1096,6 +1096,11 @@ bool RDSvc::create(const QString &name,QString *err_msg,
RDSqlQuery *q;
RDSqlQuery *q1;
if(name.simplified()!=name) {
*err_msg=QObject::tr("whitespace is not permitted in service names");
return false;
}
sql=QString("select NAME from SERVICES where ")+
"NAME=\""+RDEscapeString(name)+"\"";
q=new RDSqlQuery(sql);

View File

@ -37,7 +37,7 @@ QValidator::State RDTextValidator::validate(QString &input,int &pos) const
if(input.length()==0) {
return QValidator::Acceptable;
}
for(unsigned i=0;i<banned_chars.size();i++) {
for(int i=0;i<banned_chars.size();i++) {
if(input.contains(banned_chars.at(i))) {
return QValidator::Invalid;
}
@ -47,6 +47,12 @@ QValidator::State RDTextValidator::validate(QString &input,int &pos) const
void RDTextValidator::addBannedChar(char c)
{
banned_chars.push_back(QChar(c));
}
void RDTextValidator::addBannedChar(const QChar &c)
{
banned_chars.push_back(c);
}

View File

@ -21,9 +21,9 @@
#ifndef RDTEXTVALIDATOR_H
#define RDTEXTVALIDATOR_H
#include <vector>
#include <qvalidator.h>
#include <QChar>
#include <QList>
#include <QValidator>
class RDTextValidator : public QValidator
{
@ -31,10 +31,12 @@ class RDTextValidator : public QValidator
RDTextValidator(QObject *parent=0,const char *name=0,bool allow_quote=false);
QValidator::State validate(QString &input,int &pos) const;
void addBannedChar(char c);
void addBannedChar(const QChar &c);
static QString stripString(QString str);
private:
std::vector<char> banned_chars;
QList<QChar> banned_chars;
// std::vector<char> banned_chars;
};

View File

@ -48,10 +48,8 @@ AddSvc::AddSvc(QString *svcname,QWidget *parent)
//
// Fix the Window Size
//
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
setMinimumSize(sizeHint());
setMaximumSize(sizeHint());
setWindowTitle("RDAdmin - "+tr("Add Service"));
@ -59,6 +57,8 @@ AddSvc::AddSvc(QString *svcname,QWidget *parent)
// Text Validator
//
RDTextValidator *validator=new RDTextValidator(this);
validator->addBannedChar(QChar(' '));
validator->addBannedChar(QChar('\t'));
//
// Service Name