validate field names
check for invalid characters in field names (eg '.'). Restrict character set to ascii alpha numeric and '_'.
This commit is contained in:
@@ -65,6 +65,24 @@ static void testCreatePVStructure()
|
||||
std::cout << "testCreatePVStructure PASSED" << std::endl;
|
||||
}
|
||||
|
||||
static void testCreatePVStructureWithInvalidName()
|
||||
{
|
||||
testDiag("testCreatePVStructureWithInvalidName");
|
||||
StringArray fieldNames;
|
||||
fieldNames.push_back("ok");
|
||||
fieldNames.push_back("this.is-wrong");
|
||||
PVFieldPtrArray pvFields;
|
||||
pvFields.push_back(pvDataCreate->createPVScalar(pvString));
|
||||
pvFields.push_back(pvDataCreate->createPVScalar(pvInt));
|
||||
try{
|
||||
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
|
||||
fieldNames,pvFields);
|
||||
testFail("Creation of invalid field name '%s' was allowed", fieldNames[1].c_str());
|
||||
} catch(std::invalid_argument& e) {
|
||||
testPass("Creation of invalid field name '%s' fails as expected", fieldNames[1].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
static void testPVScalarCommon(string /*fieldName*/,ScalarType stype)
|
||||
{
|
||||
PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype);
|
||||
@@ -641,13 +659,14 @@ static void testFieldAccess()
|
||||
|
||||
MAIN(testPVData)
|
||||
{
|
||||
testPlan(242);
|
||||
testPlan(243);
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
standardField = getStandardField();
|
||||
standardPVField = getStandardPVField();
|
||||
convert = getConvert();
|
||||
testCreatePVStructure();
|
||||
testCreatePVStructureWithInvalidName();
|
||||
testPVScalar();
|
||||
testScalarArray();
|
||||
testRequest();
|
||||
|
||||
Reference in New Issue
Block a user