Fix: libcrmcommon: Escape some chars in XML attribute text output
Second half of quasi-regression introduced by c6d9cea.
When displaying XML attributes in text output format, "escape"
some special characters in the attribute value as follows:
- '\n' becomes a literal backslash ('\') followed by 'n'
- '\t' becomes a literal backslash ('\') followed by 't'
- '\r' becomes a literal backslash ('\') followed by 'r'
- '"' is backslash-escaped (becomes a literal backslash followed by '"')
We still want to keep the printed value as close as possible to the
original value that was set, so other XML special characters like '<',
'>', and '&' are printed unaltered.
attrd_updater and crm_attribute use this output method. It turns out
that the openstack-info resource agent sets a multiline attribute (which
I consider a bug, but it's longstanding behavior). The value has no
spaces other than the newlines. The openstack-virtual-ip resource agent
then depends on being able to parse it from the attrd_updater text
output as one line with no spaces.
This commit ensures that a newline character doesn't introduce a line
break or a get converted to a space.
Questionably, also we escape double quotes here. This is clearer for
human readers, though it may be no better or perhaps worse for scripts
that parse the text output.
Fixes T799
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>