ifcfg: also ANSIC escape DEL character in ifcfg writer

This is like using nm_ascii_is_ctrl_or_del() instead of
nm_ascii_is_ctrl() in the previous version of the patch.
We thus now always will switch to ANSIC escaping if we see
a ASCII DEL character. That is probable desirable, but either
way should not make a big difference (because we can parse
the DEL character both in regular quotation and in ANSIC quotation).

The patch is however larger, to also take the opportunity to only check
for nm_ascii_is_regular() in the "fast path". The behavior is the same
as changing nm_ascii_is_ctrl() to nm_ascii_is_ctrl_or_del().
This commit is contained in:
Thomas Haller 2021-07-16 09:09:03 +02:00
parent 6841bb1b26
commit fc2f758af5
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -262,13 +262,14 @@ svEscape(const char *s, char **to_free)
mangle++;
else if (_char_req_quotes(s[slen]))
requires_quotes = TRUE;
else if (nm_ascii_is_ctrl(s[slen])) {
/* if the string contains newline we can only express it using ANSI C quotation
* (as we don't support line continuation).
* Additionally, ANSI control characters look odd with regular quotation, so handle
* them too. */
return (*to_free = _escape_ansic(s));
} else if (nm_ascii_is_non_ascii(s[slen])) {
else if (!nm_ascii_is_regular(s[slen])) {
if (nm_ascii_is_ctrl_or_del(s[slen])) {
/* if the string contains newline we can only express it using ANSI C quotation
* (as we don't support line continuation).
* Additionally, ANSI control characters look odd with regular quotation, so handle
* them too. */
return (*to_free = _escape_ansic(s));
}
all_ascii = FALSE;
requires_quotes = TRUE;
}