Incorrect file database written for strings with double quotes but no spaces
Hi,
In our codebase we have a string property whose value is meant to be JSON content. In most cases this works as intended, but we started seeing issues in our tests (which use pytango's TestDeviceContext
, which in turn means using the "nodb" option under the hood) when the JSON content has double quotes (always have, because the top-level value is an object with one key) and no spaces (seen only recently, since we started generating this JSON content in a different way).
Digging down I think the issue is in these lines (and similar ones in that function): https://gitlab.com/tango-controls/cppTango/-/blob/dc266039dd0f44771abae1b3788391099f704a53/src/client/filedatabase.cpp#L1190-1200: string values are surrounded by double quotes only if they include a space, but not if they include double quotes, which are escaped in the process.
For example, when setting our property to the value "hi"
, we end up with this file:
SDPQueueConnector/sdpqueueconnector/DEVICE/SDPQueueConnector: "test/queue_connector/1"
#############################################
# CLASS SDPQueueConnector
# CLASS SDPQueueConnector attribute properties
# DEVICE test/queue_connector/1 properties
test/queue_connector/1->exchanges_json: \"hi\"
# DEVICE test/queue_connector/1 attribute properties
This seems to affect all string values that are written to the file.