From e26e0fdffd2712936f43240809dc945b158f1d62 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 20 Mar 2019 12:17:38 +0100 Subject: [PATCH] all: consider all ASCII spaces for _nm_utils_escape_spaces() and unescape --- shared/nm-utils/nm-shared-utils.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index 7789034de5..5a2070fe31 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -2422,8 +2422,6 @@ _nm_utils_user_data_unpack (gpointer user_data, int nargs, ...) /*****************************************************************************/ -#define IS_SPACE(c) NM_IN_SET ((c), ' ', '\t') - const char * _nm_utils_escape_spaces (const char *str, char **to_free) { @@ -2438,7 +2436,7 @@ _nm_utils_escape_spaces (const char *str, char **to_free) while (TRUE) { if (!*ptr) return str; - if (IS_SPACE (*ptr)) + if (g_ascii_isspace (*ptr)) break; ptr++; } @@ -2448,7 +2446,7 @@ _nm_utils_escape_spaces (const char *str, char **to_free) r = ret; *to_free = ret; while (*ptr) { - if (IS_SPACE (*ptr)) + if (g_ascii_isspace (*ptr)) *r++ = '\\'; *r++ = *ptr++; } @@ -2468,13 +2466,13 @@ _nm_utils_unescape_spaces (char *str, gboolean do_strip) return NULL; if (do_strip) { - while (str[i] && IS_SPACE (str[i])) + while (str[i] && g_ascii_isspace (str[i])) i++; } for (; str[i]; i++) { if ( str[i] == '\\' - && IS_SPACE (str[i+1])) { + && g_ascii_isspace (str[i+1])) { preserve_space_at = j; i++; } @@ -2484,15 +2482,13 @@ _nm_utils_unescape_spaces (char *str, gboolean do_strip) if (do_strip && j > 0) { while ( --j > preserve_space_at - && IS_SPACE (str[j])) + && g_ascii_isspace (str[j])) str[j] = '\0'; } return str; } -#undef IS_SPACE - /*****************************************************************************/ typedef struct {