From 674264db3dd55c9af96ffefac546637c745f9289 Mon Sep 17 00:00:00 2001 From: Jesus Vasquez Date: Mon, 8 Mar 2021 19:29:37 -0800 Subject: [PATCH] pvput: when we accept a bare value with a "=" char, verify if the ".value" field is of type "string" --- pvtoolsSrc/pvput.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/pvtoolsSrc/pvput.cpp b/pvtoolsSrc/pvput.cpp index 9efe813..00c95ea 100644 --- a/pvtoolsSrc/pvput.cpp +++ b/pvtoolsSrc/pvput.cpp @@ -106,22 +106,33 @@ struct Putter : public pvac::ClientChannel::PutCallback typedef std::vector pairs_t; pairs_t pairs; - for(size_t i=0, N=values.size(); igetSubField(fname)); + if(fld) { + // The "field" exist. Treat this input as a filed=value pair. + pairs.push_back(std::make_pair(fname, values[i].substr(sep+1))); + } else { + // If the "field" does not exist, this could be a bare value containing a "=" char. + // The ".value" field must exist and be of type "string". Otherwise, the field was + // incorrect and we ignore it. + pvd::PVFieldPtr fldv(root->getSubFieldT("value")); + if (fldv) { + if ((pvd::scalar==fldv->getField()->getType()) && (0==fldv->getField()->getID().compare("string"))) + // Tread it as a bare value + bare.push_back(values[i]); + else + // Ignore it + fprintf(stderr, "%s : Warning: no such field. Ignoring it.\n", fname.c_str()); + } + } } }