This RFC shows one possible approach for escaping strings for the json
output of telemetry library. For now this RFC supports escaping strings
for the cases of returning a single string, or returning an array of
strings. Not done is escaping of strings in objs/dicts [see more below
on TODO]

As well as telemetry lib changes, this patchset includes unit tests for
the above and also little bit of cleanup to the json tests.

TODO:
Beyond what is here in this RFC:

1. we need to decide what to do about name/value pairs. Personally, I
   think we should add the restriction to the "rte_tel_data_add_obj_*" APIs
   to only allow a defined subset of characters in names: e.g. alphanumeric
   chars, underscore and dash. That means that we only need to escape
   the data part in the case of string returns.

2. once agreed, need to implement a patch to escape strings in
   dicts/objs

3. need to add a patch to escape the input command if it contains
   invalid chars

4. some small refactoring of the main telemetry.c json-encoding function
   may be possible.

Bruce Richardson (6):
  test/telemetry_json: print success or failure per subtest
  telemetry: fix escaping of invalid json characters
  telemetry: use json string function for string outputs
  test/telemetry_json: add test for string character escaping
  telemetry: add escaping of strings in arrays
  test/telemetry-json: add test case for escaping strings in arrays

 app/test/test_telemetry_json.c | 74 +++++++++++++++++++++++++++++-----
 lib/telemetry/telemetry.c      | 11 +++--
 lib/telemetry/telemetry_json.h | 62 ++++++++++++++++++++++++++--
 3 files changed, 132 insertions(+), 15 deletions(-)

--
2.34.1

Reply via email to