From 8d70dd5477329e02bf8b9b5683216f39477b57bc Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 Jul 2021 09:09:03 +0200 Subject: [PATCH] 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(). (cherry picked from commit fc2f758af52bf5d39bd4a9b96c30345692971fdb) --- src/core/settings/plugins/ifcfg-rh/shvar.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/settings/plugins/ifcfg-rh/shvar.c b/src/core/settings/plugins/ifcfg-rh/shvar.c index 1070448826..d82efb3cb9 100644 --- a/src/core/settings/plugins/ifcfg-rh/shvar.c +++ b/src/core/settings/plugins/ifcfg-rh/shvar.c @@ -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; }